From 0656975d98d1c697acd8b4c02fb71e51ec36b020 Mon Sep 17 00:00:00 2001 From: Aaron Suggs Date: Wed, 8 Aug 2012 15:25:13 -0400 Subject: [PATCH] Clarify readme --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 268db97..032afca 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,11 @@ Note that `req` is a [Rack::Request](http://rack.rubyforge.org/doc/classes/Rack/ ## Responses -Customize the response of throttled requests using an object that adheres to the [Rack app interface](http://rack.rubyforge.org/doc/SPEC.html). +Customize the response of blacklisted and throttled requests using an object that adheres to the [Rack app interface](http://rack.rubyforge.org/doc/SPEC.html). + + Rack:Attack.blacklisted_response = lambda do |env| + [ 503, {}, ['Blocked']] + end Rack:Attack.throttled_response = lambda do |env| # name and other data about the matched throttle @@ -96,16 +100,9 @@ Customize the response of throttled requests using an object that adheres to the [ 503, {}, [body]] end -Similarly for blacklisted responses: +For responses that did not exceed a throttle limit, Rack::Attack annotates the env with match data: - Rack:Attack.blacklisted_response = lambda do |env| - [ 503, {}, ['Blocked']] - end - -For responses that did not exceed a throttle limit, Rack::Attack annotates the environment with match data. -For example, in out `reqs/ip` throttle above, a matching request would have: - - request.env['rack.attack.throttle_data']['req/ip'] # => { :period => 1, :limit => 5, :count => n } + request.env['rack.attack.throttle_data'][name] # => { :count => n, :period => p, :limit => l } ## Logging & Instrumentation