mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
Merge pull request #416 from lmansur/fix-readme
Update README example with new ActiveSupport Notification syntax
This commit is contained in:
commit
34e221acc6
1 changed files with 2 additions and 2 deletions
|
|
@ -285,9 +285,9 @@ Rack::Attack.track("special_agent", limit: 6, period: 60) do |req|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Track it using ActiveSupport::Notification
|
# Track it using ActiveSupport::Notification
|
||||||
ActiveSupport::Notifications.subscribe("rack.attack") do |name, start, finish, request_id, payload|
|
ActiveSupport::Notifications.subscribe("track.rack_attack") do |name, start, finish, request_id, payload|
|
||||||
req = payload[:request]
|
req = payload[:request]
|
||||||
if req.env['rack.attack.matched'] == "special_agent" && req.env['rack.attack.match_type'] == :track
|
if req.env['rack.attack.matched'] == "special_agent"
|
||||||
Rails.logger.info "special_agent: #{req.path}"
|
Rails.logger.info "special_agent: #{req.path}"
|
||||||
STATSD.increment("special_agent")
|
STATSD.increment("special_agent")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue