Class: Rack::MethodOverride
- Inherits:
-
Object
- Object
- Rack::MethodOverride
- Defined in:
- lib/rack/methodoverride.rb
Constant Summary collapse
- HTTP_METHODS =
%w(GET HEAD PUT POST DELETE OPTIONS)
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ MethodOverride
constructor
A new instance of MethodOverride.
Constructor Details
#initialize(app) ⇒ MethodOverride
Returns a new instance of MethodOverride.
5 6 7 |
# File 'lib/rack/methodoverride.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack/methodoverride.rb', line 9 def call(env) if env["REQUEST_METHOD"] == "POST" req = Request.new(env) method = req.POST["_method"].upcase if HTTP_METHODS.include?(method) env["REQUEST_METHOD"] = method end end @app.call(env) end |