prop 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/prop.rb +1 -1
- data/lib/prop/middleware.rb +2 -2
- data/prop.gemspec +1 -1
- data/test/test_middleware.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -74,9 +74,9 @@ Prop ships with a built in Rack middleware that you can use to do all the except
|
|
74
74
|
|
75
75
|
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.
|
76
76
|
|
77
|
-
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, feel free to replace it with your own - you can set the error handler to anything that responds to `.call` and takes a `RateLimited` instance as argument:
|
77
|
+
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, feel free to replace it with your own - you can set the error handler to anything that responds to `.call` and takes the environment and a `RateLimited` instance as argument:
|
78
78
|
|
79
|
-
error_handler = Proc.new do |error|
|
79
|
+
error_handler = Proc.new do |env, error|
|
80
80
|
body = error.description || "This action has been rate limited"
|
81
81
|
headers = { "Content-Type" => "text/plain", "Content-Length" => body.size, "Retry-After" => error.retry_after }
|
82
82
|
|
data/lib/prop.rb
CHANGED
data/lib/prop/middleware.rb
CHANGED
@@ -6,7 +6,7 @@ module Prop
|
|
6
6
|
|
7
7
|
# Default error handler
|
8
8
|
class DefaultErrorHandler
|
9
|
-
def self.call(error)
|
9
|
+
def self.call(env, error)
|
10
10
|
body = error.description || "This action has been rate limited"
|
11
11
|
headers = { "Content-Type" => "text/plain", "Content-Length" => body.size, "Retry-After" => error.retry_after }
|
12
12
|
|
@@ -24,7 +24,7 @@ module Prop
|
|
24
24
|
begin
|
25
25
|
@app.call(env)
|
26
26
|
rescue Prop::RateLimited => e
|
27
|
-
@handler.call(e)
|
27
|
+
@handler.call(env, e)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/prop.gemspec
CHANGED
@@ -13,7 +13,7 @@ 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.
|
16
|
+
s.version = '0.7.2'
|
17
17
|
s.date = '2012-04-06'
|
18
18
|
s.rubyforge_project = 'prop'
|
19
19
|
|
data/test/test_middleware.rb
CHANGED
@@ -35,7 +35,7 @@ class TestMiddleware < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
context "with a custom error handler" do
|
37
37
|
setup do
|
38
|
-
@middleware = Prop::Middleware.new(@app, :error_handler => Proc.new { |error| "Oops" })
|
38
|
+
@middleware = Prop::Middleware.new(@app, :error_handler => Proc.new { |env, error| "Oops" })
|
39
39
|
end
|
40
40
|
|
41
41
|
should "allow setting a custom error handler" do
|
metadata
CHANGED