mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
refactor: DRY setting config defaults
This commit is contained in:
parent
55cb6def03
commit
0188a90ab2
1 changed files with 7 additions and 10 deletions
|
|
@ -21,16 +21,7 @@ module Rack
|
|||
attr_accessor :blocklisted_response, :throttled_response, :throttled_response_retry_after_header
|
||||
|
||||
def initialize
|
||||
@safelists = {}
|
||||
@blocklists = {}
|
||||
@throttles = {}
|
||||
@tracks = {}
|
||||
@anonymous_blocklists = []
|
||||
@anonymous_safelists = []
|
||||
@throttled_response_retry_after_header = false
|
||||
|
||||
@blocklisted_response = DEFAULT_BLOCKLISTED_RESPONSE
|
||||
@throttled_response = DEFAULT_THROTTLED_RESPONSE
|
||||
set_defaults
|
||||
end
|
||||
|
||||
def safelist(name = nil, &block)
|
||||
|
|
@ -92,6 +83,12 @@ module Rack
|
|||
end
|
||||
|
||||
def clear_configuration
|
||||
set_defaults
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_defaults
|
||||
@safelists = {}
|
||||
@blocklists = {}
|
||||
@throttles = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue