diff --git a/README.md b/README.md index 278c224..2431616 100644 --- a/README.md +++ b/README.md @@ -188,11 +188,16 @@ end ### Tracks ```ruby -# Track requests from a special user agent, supports limit and period options like throttle. +# Track requests from a special user agent. Rack::Attack.track("special_agent") do |req| req.user_agent == "SpecialAgent" end +# Supports optional limit and period, triggers the notification only when the limit is reached. +Rack::Attack.track("special_agent", :limit 6, :period => 60.seconds) do |req| + req.user_agent == "SpecialAgent" +end + # Track it using ActiveSupport::Notification ActiveSupport::Notifications.subscribe("rack.attack") do |name, start, finish, request_id, req| if req.env['rack.attack.matched'] == "special_agent" && req.env['rack.attack.match_type'] == :track