forked from OpenNeo/impress
Fix deprecation warning in Rack::Attack
Looking at the docs, I think what changed is that `throttled_responder` gets the request as an argument instead of the `env`? And has the same return type for the lambda as before? So uhhh I don't remember how to test this, but uhh it's not crashing when the server starts anymore, and I feel like the most likely problem here would be that you get a 500 instead of a useful response in the rate limit case, so like. ehh I'll just leave it be!
This commit is contained in:
parent
5556873eaa
commit
bb20925382
1 changed files with 2 additions and 3 deletions
|
@ -7,9 +7,8 @@ PETS_THROTTLE_MESSAGE = "We've received a lot of pet names from you " +
|
|||
"recently, so we're giving our servers a break. Try " +
|
||||
"again in a minute or so. Thanks!"
|
||||
|
||||
Rack::Attack.throttled_response = lambda do |env|
|
||||
if env['rack.attack.matched'] == 'pets/ip'
|
||||
req = ActionDispatch::Request.new(env)
|
||||
Rack::Attack.throttled_responder = lambda do |req|
|
||||
if req.env['rack.attack.matched'] == 'pets/ip'
|
||||
if req.path.end_with?('.json')
|
||||
[503, {}, [PETS_THROTTLE_MESSAGE]]
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue