1
0
Fork 0
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:
Emi Matchu 2023-08-22 16:19:07 -07:00
parent 5556873eaa
commit bb20925382

View file

@ -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 " + "recently, so we're giving our servers a break. Try " +
"again in a minute or so. Thanks!" "again in a minute or so. Thanks!"
Rack::Attack.throttled_response = lambda do |env| Rack::Attack.throttled_responder = lambda do |req|
if env['rack.attack.matched'] == 'pets/ip' if req.env['rack.attack.matched'] == 'pets/ip'
req = ActionDispatch::Request.new(env)
if req.path.end_with?('.json') if req.path.end_with?('.json')
[503, {}, [PETS_THROTTLE_MESSAGE]] [503, {}, [PETS_THROTTLE_MESSAGE]]
else else