From 1857f8dd579367cf9c09d74bde0649a2f0239884 Mon Sep 17 00:00:00 2001 From: Paul Coates Date: Mon, 19 May 2014 12:30:18 -0700 Subject: [PATCH] Added track with limit/period options example to the README.md for clarity. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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