mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +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
|
attr_accessor :blocklisted_response, :throttled_response, :throttled_response_retry_after_header
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@safelists = {}
|
set_defaults
|
||||||
@blocklists = {}
|
|
||||||
@throttles = {}
|
|
||||||
@tracks = {}
|
|
||||||
@anonymous_blocklists = []
|
|
||||||
@anonymous_safelists = []
|
|
||||||
@throttled_response_retry_after_header = false
|
|
||||||
|
|
||||||
@blocklisted_response = DEFAULT_BLOCKLISTED_RESPONSE
|
|
||||||
@throttled_response = DEFAULT_THROTTLED_RESPONSE
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def safelist(name = nil, &block)
|
def safelist(name = nil, &block)
|
||||||
|
|
@ -92,6 +83,12 @@ module Rack
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_configuration
|
def clear_configuration
|
||||||
|
set_defaults
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_defaults
|
||||||
@safelists = {}
|
@safelists = {}
|
||||||
@blocklists = {}
|
@blocklists = {}
|
||||||
@throttles = {}
|
@throttles = {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue