version 2.3.0, update changelog, copy tweaks

This commit is contained in:
Aaron Suggs 2013-08-20 11:39:44 -04:00
parent b7ebb58bd9
commit 1d367f5acd
4 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,8 @@
# Changlog
## v2.3.0 - unlreleased (master)
* Allow throttle `limit` argument to be a proc. (thanks @lunks)
## v2.2.1 - 13 August 2013
* Add license to gemspec
* Support ruby version 1.9.2

View file

@ -150,7 +150,7 @@ how the parameters work.
# You can also set a limit using a proc instead of a number. For
# instance, after Rack::Auth::Basic has authenticated the user:
limit_based_on_proc = proc {|req| req.env["REMOTE_USER"] == "god" ? 100 : 1}
limit_based_on_proc = proc {|req| req.env["REMOTE_USER"] == "admin" ? 100 : 1}
Rack::Attack.throttle('req/ip', :limit => limit_based_on_proc, :period => 1.second) do |req|
req.ip
end

View file

@ -1,5 +1,5 @@
module Rack
module Attack
VERSION = '2.2.1'
VERSION = '2.3.0'
end
end

View file

@ -43,7 +43,7 @@ describe 'Rack::Attack.throttle with limit as proc' do
before do
@period = 60 # Use a long period; failures due to cache key rotation less likely
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
Rack::Attack.throttle('ip/sec', :limit => lambda {|env| 1}, :period => @period) { |req| req.ip }
Rack::Attack.throttle('ip/sec', :limit => lambda {|req| 1}, :period => @period) { |req| req.ip }
end
allow_ok_requests