Class: RestfulJSONP::MethodOverride

Inherits:
Rack::MethodOverride
  • Object
show all
Defined in:
lib/restful_jsonp/method_override.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/restful_jsonp/method_override.rb', line 5

def call(env)
  req = Rack::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
 
  @app.call(env)
end