Class: Rack::MethodOverrideWithParams

Inherits:
MethodOverride
  • Object
show all
Defined in:
lib/rack/methodoverride-with-params.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rack/methodoverride-with-params.rb', line 6

def call(env)
  if env["REQUEST_METHOD"] == "POST"
    req = Request.new(env)
    method = req.params[METHOD_OVERRIDE_PARAM_KEY] ||
      env[HTTP_METHOD_OVERRIDE_HEADER]
    method = method.to_s.upcase
    if HTTP_METHODS.include?(method)
      env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
      env["REQUEST_METHOD"] = method
    end
  end

  @app.call(env)

end