README in rack-throttle-0.3.0 vs README in rack-throttle-0.4.0
- old
+ new
@@ -1,22 +1,22 @@
HTTP Request Rate Limiter for Rack Applications
===============================================
This is [Rack][] middleware that provides logic for rate-limiting incoming
HTTP requests to Rack applications. You can use `Rack::Throttle` with any
-Ruby web framework based on Rack, including with Ruby on Rails 3.0 and with
+Ruby web framework based on Rack, including with Ruby on Rails and with
Sinatra.
-* <http://github.com/datagraph/rack-throttle>
+* <https://github.com/bendiken/rack-throttle>
Features
--------
* Throttles a Rack application by enforcing a minimum time interval between
subsequent HTTP requests from a particular client, as well as by defining
- a maximum number of allowed HTTP requests per a given time period (hourly
- or daily).
+ a maximum number of allowed HTTP requests per a given time period (per minute,
+ hourly, or daily).
* Compatible with any Rack application and any Rack-based framework.
* Stores rate-limiting counters in any key/value store implementation that
responds to `#[]`/`#[]=` (like Ruby's hashes) or to `#get`/`#set` (like
memcached or Redis).
* Compatible with the [gdbm][] binding included in Ruby's standard library.
@@ -26,22 +26,46 @@
(currently available as a free beta service).
Examples
--------
-### Adding throttling to a Rackup application
+### Adding throttling to a Rails application
+ # config/application.rb
require 'rack/throttle'
+
+ class Application < Rails::Application
+ config.middleware.use Rack::Throttle::Interval
+ end
+### Adding throttling to a Sinatra application
+
+ #!/usr/bin/env ruby -rubygems
+ require 'sinatra'
+ require 'rack/throttle'
+
use Rack::Throttle::Interval
+
+ get('/hello') { "Hello, world!\n" }
+### Adding throttling to a Rackup application
+
+ #!/usr/bin/env rackup
+ require 'rack/throttle'
+
+ use Rack::Throttle::Interval
+
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, world!\n"] }
### Enforcing a minimum 3-second interval between requests
use Rack::Throttle::Interval, :min => 3.0
+### Allowing a maximum of 60 requests per minute
+
+ use Rack::Throttle::Minute, :max => 60
+
### Allowing a maximum of 100 requests per hour
use Rack::Throttle::Hourly, :max => 100
### Allowing a maximum of 1,000 requests per day
@@ -50,10 +74,11 @@
### Combining various throttling constraints into one overall policy
use Rack::Throttle::Daily, :max => 1000 # requests
use Rack::Throttle::Hourly, :max => 100 # requests
+ use Rack::Throttle::Minute, :max => 60 # requests
use Rack::Throttle::Interval, :min => 3.0 # seconds
### Storing the rate-limiting counters in a GDBM database
require 'gdbm'
@@ -134,60 +159,65 @@
limiting an HTTP 403 response is more appropriate. Nonetheless, if you think
otherwise, `Rack::Throttle` does allow you to override the returned HTTP
status code by passing in a `:code => 503` option when constructing a
`Rack::Throttle::Limiter` instance.
-Documentation
--------------
-
-<http://datagraph.rubyforge.org/rack-throttle/>
-
-* {Rack::Throttle}
- * {Rack::Throttle::Interval}
- * {Rack::Throttle::Daily}
- * {Rack::Throttle::Hourly}
-
Dependencies
------------
* [Rack](http://rubygems.org/gems/rack) (>= 1.0.0)
Installation
------------
-The recommended installation method is via RubyGems. To install the latest
-official release, do:
+The recommended installation method is via [RubyGems](http://rubygems.org/).
+To install the latest official release of the gem, do:
% [sudo] gem install rack-throttle
-Download
---------
+Authors
+-------
-To get a local working copy of the development repository, do:
+* [Arto Bendiken](https://gratipay.com/bendiken) - <http://ar.to/>
- % git clone git://github.com/datagraph/rack-throttle.git
+Contributors
+------------
-Alternatively, you can download the latest development version as a tarball
-as follows:
+* [Brendon Murphy](https://github.com/bemurphy)
+* [Hendrik Kleinwaechter](https://github.com/hendricius)
+* [Karel Minarik](https://github.com/karmi)
+* [Keita Urashima](https://github.com/ursm)
+* [Leonid Beder](https://github.com/lbeder)
+* [TJ Singleton](https://github.com/tjsingleton)
+* [Winfield Peterson](https://github.com/wpeterson)
- % wget http://github.com/datagraph/rack-throttle/tarball/master
+Contributing
+------------
-Authors
--------
+* Do your best to adhere to the existing coding conventions and idioms.
+* Don't use hard tabs, and don't leave trailing whitespace on any line.
+ Before committing, run `git diff --check` to make sure of this.
+* Do document every method you add using [YARD][] annotations. Read the
+ [tutorial][YARD-GS] or just look at the existing code for examples.
+* Don't touch the gemspec or `VERSION` files. If you need to change them,
+ do so on your private branch only.
+* Do feel free to add yourself to the `CREDITS` file and the
+ corresponding list in the the `README`. Alphabetical order applies.
+* Don't touch the `AUTHORS` file. If your contributions are significant
+ enough, be assured we will eventually add you in there.
-* [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>
-* [Brendon Murphy](mailto:disposable.20.xternal@spamourmet.com>) - <http://www.techfreak.net/>
-
License
-------
-`Rack::Throttle` is free and unencumbered public domain software. For more
-information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
+This is free and unencumbered public domain software. For more information,
+see <http://unlicense.org/> or the accompanying `UNLICENSE` file.
[Rack]: http://rack.rubyforge.org/
[gdbm]: http://ruby-doc.org/stdlib/libdoc/gdbm/rdoc/classes/GDBM.html
[memcached]: http://rubygems.org/gems/memcached
[memcache-client]: http://rubygems.org/gems/memcache-client
[memcache]: http://rubygems.org/gems/memcache
[redis]: http://rubygems.org/gems/redis
[Heroku]: http://heroku.com/
[Heroku memcache]: http://docs.heroku.com/memcache
+[YARD]: http://yardoc.org/
+[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md