mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Better cache interface
This commit is contained in:
parent
e135f17386
commit
6784f21612
2 changed files with 6 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ module Rack::Attack
|
|||
|
||||
class << self
|
||||
|
||||
attr_accessor :cache, :notifier, :blacklisted_response, :throttled_response
|
||||
attr_accessor :notifier, :blacklisted_response, :throttled_response
|
||||
|
||||
def whitelist(name, &block)
|
||||
self.whitelists[name] = Whitelist.new(name, block)
|
||||
|
|
@ -29,7 +29,6 @@ module Rack::Attack
|
|||
@app = app
|
||||
|
||||
# Set defaults
|
||||
@cache ||= Cache.new
|
||||
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
|
||||
@blacklisted_response ||= lambda {|env| [503, {}, ['Blocked']] }
|
||||
@throttled_response ||= lambda {|env|
|
||||
|
|
@ -78,6 +77,10 @@ module Rack::Attack
|
|||
notifier.instrument('rack.attack', req) if notifier
|
||||
end
|
||||
|
||||
def cache
|
||||
@cache ||= Cache.new
|
||||
end
|
||||
|
||||
def clear!
|
||||
@whitelists, @blacklists, @throttles = {}, {}, {}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
module Rack
|
||||
module Attack
|
||||
VERSION = '1.1.0'
|
||||
VERSION = '1.2.0'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue