prop 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/lib/prop.rb +1 -1
- data/lib/prop/middleware.rb +1 -1
- data/prop.gemspec +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -77,7 +77,7 @@ Prop ships with a built in Rack middleware that you can use to do all the except
|
|
77
77
|
|
78
78
|
Where `Retry-After` is the number of seconds the client has to wait before retrying this end point. The body of this response is whatever description Prop has configured for the throttle that got violated, or a default string if there's none configured.
|
79
79
|
|
80
|
-
If you wish to do manual error messaging in these cases, you can define an error handler in your Prop configuration. Here's how the default error handler looks
|
80
|
+
If you wish to do manual error messaging in these cases, you can define an error handler in your Prop configuration. Here's how the default error handler looks - you use anything that responds to `.call` and takes the environment and a `RateLimited` instance as argument:
|
81
81
|
|
82
82
|
error_handler = Proc.new do |env, error|
|
83
83
|
body = error.description || "This action has been rate limited"
|
@@ -88,6 +88,8 @@ If you wish to do manual error messaging in these cases, you can define an error
|
|
88
88
|
|
89
89
|
ActionController::Dispatcher.middleware.insert_before(ActionController::ParamsParser, :error_handler => error_handler)
|
90
90
|
|
91
|
+
An alternative to this, is to extend `Prop::Middleware` and override the `render_response(env, error)` method.
|
92
|
+
|
91
93
|
## Disabling Prop
|
92
94
|
|
93
95
|
In case you need to perform e.g. a manual bulk operation:
|
data/lib/prop.rb
CHANGED
data/lib/prop/middleware.rb
CHANGED
@@ -8,7 +8,7 @@ module Prop
|
|
8
8
|
class DefaultErrorHandler
|
9
9
|
def self.call(env, error)
|
10
10
|
body = error.description || "This action has been rate limited"
|
11
|
-
headers = { "Content-Type" => "text/plain", "Content-Length" => body.size, "Retry-After" => error.retry_after }
|
11
|
+
headers = { "Content-Type" => "text/plain", "Content-Length" => "#{body.size}", "Retry-After" => "#{error.retry_after}" }
|
12
12
|
|
13
13
|
[ 429, headers, [ body ]]
|
14
14
|
end
|
data/prop.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'prop'
|
16
|
-
s.version = '0.7.
|
17
|
-
s.date = '2012-04-
|
16
|
+
s.version = '0.7.7'
|
17
|
+
s.date = '2012-04-07'
|
18
18
|
s.rubyforge_project = 'prop'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 7
|
10
|
+
version: 0.7.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|