Rack::CheckHttpMethodAllowed
Rack middleware to check HTTP request methods and reject ones you don't want.
Installation
Add this line to your application's Gemfile:
gem 'rack-check_http_method_allowed'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-check_http_method_allowed
Usage
In config/application.rb
inside the main configuration block, add the line:
config.middleware.use 'Rack::CheckHttpMethodAllowed'
By default, this middleware only allows through methods conforming to RFC2616 and RFC5789, which should cover most applications, since the rest are mainly for WebDAV support.
If you need to support a different set of HTTP methods, you can pass them in like so:
config.middleware.use 'Rack::CheckHttpMethodAllowed', ['GET', 'POST', 'SOMETHINGELSE']
and any methods not listed will be rejected.
Rails maintains a list of HTTP verbs that it can handle in ActionController::Request::HTTP_METHODS, (including WebDAV methods), you can use this instead like so:
config.middleware.use 'Rack::CheckHttpMethodAllowed', ActionController::Request::HTTP_METHODS
Contributing
- Fork it ( http://github.com/getfretless/rack-check_http_method_allowed/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request