rack/rack — pull request #687 by dwilkie (2014-05-17 06:56:27+00:00)
Title: Refactor methodoverride to make it easier to inherit and extend

The purpose of this refactor is to make it simpler to inherit from Rack::MethodOverride and enable method override for methods other than POST.

For example consider an app which needs to respond to `jsonp` requests such as Stripe (See also https://stripe.com/blog/stripejs-and-jsonp)

With this change you can now do

```ruby
# app/middleware/bongloy/methodoverride.rb
module Bongloy
class MethodOverride < ::Rack::MethodOverride

private

def allowed_methods
super + ["GET"]
end

def method_override_param(req)
super || req.GET[METHOD_OVERRIDE_PARAM_KEY]
end
end
```

```ruby
# config/application.rb

config.middleware.swap(Rack::MethodOverride, "Bongloy::MethodOverride")
```