mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Merge pull request #93 from gsamokovarov/dont-rescue-nil
Avoid rescue nil in the default throttled response
This commit is contained in:
commit
a1cedbbc7e
1 changed files with 1 additions and 1 deletions
|
|
@ -82,7 +82,7 @@ class Rack::Attack
|
|||
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
|
||||
@blacklisted_response = lambda {|env| [403, {'Content-Type' => 'text/plain'}, ["Forbidden\n"]] }
|
||||
@throttled_response = lambda {|env|
|
||||
retry_after = env['rack.attack.match_data'][:period] rescue nil
|
||||
retry_after = (env['rack.attack.match_data'] || {})[:period]
|
||||
[429, {'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue