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