README.md in raterr-0.1.0 vs README.md in raterr-0.1.1

- old
+ new

@@ -1,10 +1,11 @@ # Raterr [![Build Status](https://travis-ci.org/wizardone/raterr.svg?branch=master)](https://travis-ci.org/wizardone/raterr) [![codecov](https://codecov.io/gh/wizardone/raterr/branch/master/graph/badge.svg)](https://codecov.io/gh/wizardone/raterr) -`Raterr` allows you to enforce rate limiting restrictions on visitors +`Raterr` allows you to enforce rate limiting restrictions based on ip +address. ## Installation Add this line to your application's Gemfile: @@ -33,13 +34,17 @@ ``` To enforce rate limiting use: ```ruby Raterr.enforce(request, period: :minute, max: 200, code: 429) ``` +`request` might be any data type that has an `ip` method. For Rails +applications that would be the request method. + The result of `Raterr.enforce` is always a pseudo status. In case the rate limit has not been reached you will get a pseudo `200` status + the -number of attempts. This allows you to do additional checks. If +number of attempts made. This allows you to do additional checks (say a +warning if you are about to reach the threshhold). If it has been reached you will get whatever status you configured, or the default one, which is 429 + a text message. An example usage in a Rails application would be: ```ruby @@ -66,12 +71,12 @@ If you want to add limiting to the whole app you would put it in an application controller and so on... You can configure the period error code and the max attempts. The allowed periods are: `:minute, :hour, :day`. +The default error code is `429`. +The default max attempts is `100`. -Currently `Raterr` checks the unique ip address of the visitor to -determine the amount of visits. ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).