Merge pull request #416 from lmansur/fix-readme

Update README example with new ActiveSupport Notification syntax
This commit is contained in:
Gonzalo Rodriguez 2019-05-24 11:24:01 -03:00 committed by GitHub
commit 34e221acc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -285,9 +285,9 @@ Rack::Attack.track("special_agent", limit: 6, period: 60) do |req|
end
# 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]
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}"
STATSD.increment("special_agent")
end