This package is unmaintained. If you would like to maintain this package, please get in contact.
This gem is a Rack Middleware to reject requests.
Add this line to your application's Gemfile:
gem 'rack-rejector'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-rejector
You still have to write the conditions for rejection on your own. The rest is handled by this gem. It will reject the request if the given block evaluates to true. This example would grant access only to GET requests:
use Rack::Rejector, body: 'No Teapot' do |request, options|
!request.get?
end
Available options are:
options.body = "I'm a teapot" # Default: '503 SERVICE UNAVAILABLE'
options.code = 418 # Default: 503
options.headers = { 'x-teapot' => 'teapot' } # Default: {}
You can set them either at initialization or override them in the block.
After checking out the repo, run bundle
to install dependencies. Then, run bundle exec rake
to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/ivx/rack-rejector.