0.0
Repository is archived
No release in over 3 years
This gem is a Rack Middleware to reject requests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.0
~> 3.0
~> 0.71

Runtime

>= 0
 Project Readme

Unmaintained

This package is unmaintained. If you would like to maintain this package, please get in contact.

Rack::Rejector

This gem is a Rack Middleware to reject requests.

Installation

Add this line to your application's Gemfile:

gem 'rack-rejector'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-rejector

Usage

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.

Development

After checking out the repo, run bundle to install dependencies. Then, run bundle exec rake to run the tests.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ivx/rack-rejector.