Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Build Status

Bottleneck

Bottleneck - simple Redis based requests limiter.

Installation

Add this line to your application's Gemfile:

gem 'bottleneck'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bottleneck

Usage

Create two yaml files in config dir:

bottleneck.yml

limits:
  time_period_seconds: 3600
  max_requests_count: 100

redis.yml

host: 'localhost'
port: 6379

Add before action to your controller:

class ApplicationController < ActionController::API
  before_action :check_limit

  private

  def check_limit
    result = Bottleneck.check(request.remote_ip)
    render status: result[:status], json: { message: result[:message] }
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/maratgaliev/bottleneck.

License

The gem is available as open source under the terms of the MIT License.

About

Simple Redis based rate limiter for Rails

Resources

License

Releases

No releases published

Packages

No packages published