Tidy up defaults. We don't need to use ||= because this runs when the class gets loaded, and we won't have user supplied defaults yet.

This commit is contained in:
Steve Hodgkiss 2014-04-02 17:12:06 +11:00
parent 332dd4ff9e
commit 93421efa5a

View file

@ -76,9 +76,9 @@ class Rack::Attack
end
# Set defaults
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blacklisted_response ||= lambda {|env| [403, {}, ["Forbidden\n"]] }
@throttled_response ||= lambda {|env|
@notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blacklisted_response = lambda {|env| [403, {}, ["Forbidden\n"]] }
@throttled_response = lambda {|env|
retry_after = env['rack.attack.match_data'][:period] rescue nil
[429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
}