mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
feat: deprecate throttled_response and blocklisted_response
This commit is contained in:
parent
8bf9d4efad
commit
aaeff6d0ae
3 changed files with 12 additions and 10 deletions
|
|
@ -25,16 +25,14 @@ module Rack
|
|||
attr_reader :blocklisted_response, :throttled_response # Keeping these for backwards compatibility
|
||||
|
||||
def blocklisted_response=(responder)
|
||||
# TODO: uncomment in 7.0
|
||||
# warn "[DEPRECATION] Rack::Attack.blocklisted_response is deprecated. "\
|
||||
# "Please use Rack::Attack.blocklisted_responder instead."
|
||||
warn "[DEPRECATION] Rack::Attack.blocklisted_response is deprecated. "\
|
||||
"Please use Rack::Attack.blocklisted_responder instead."
|
||||
@blocklisted_response = responder
|
||||
end
|
||||
|
||||
def throttled_response=(responder)
|
||||
# TODO: uncomment in 7.0
|
||||
# warn "[DEPRECATION] Rack::Attack.throttled_response is deprecated. "\
|
||||
# "Please use Rack::Attack.throttled_responder instead"
|
||||
warn "[DEPRECATION] Rack::Attack.throttled_response is deprecated. "\
|
||||
"Please use Rack::Attack.throttled_responder instead"
|
||||
@throttled_response = responder
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,10 @@ describe "Customizing block responses" do
|
|||
|
||||
assert_equal 403, last_response.status
|
||||
|
||||
Rack::Attack.blocklisted_response = lambda do |_env|
|
||||
[503, {}, ["Blocked"]]
|
||||
silence_warnings do
|
||||
Rack::Attack.blocklisted_response = lambda do |_env|
|
||||
[503, {}, ["Blocked"]]
|
||||
end
|
||||
end
|
||||
|
||||
get "/", {}, "REMOTE_ADDR" => "1.2.3.4"
|
||||
|
|
|
|||
|
|
@ -68,8 +68,10 @@ describe "Customizing throttled response" do
|
|||
|
||||
assert_equal 429, last_response.status
|
||||
|
||||
Rack::Attack.throttled_response = lambda do |_req|
|
||||
[503, {}, ["Throttled"]]
|
||||
silence_warnings do
|
||||
Rack::Attack.throttled_response = lambda do |_req|
|
||||
[503, {}, ["Throttled"]]
|
||||
end
|
||||
end
|
||||
|
||||
get "/", {}, "REMOTE_ADDR" => "1.2.3.4"
|
||||
|
|
|
|||
Loading…
Reference in a new issue