Class: Jsonp::MethodOverride
- Inherits:
-
Object
- Object
- Jsonp::MethodOverride
- Defined in:
- lib/jsonp/method_override.rb
Overview
Allows overwriting of HTTP method also in JSONP GET HTTP requests.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ MethodOverride
constructor
A new instance of MethodOverride.
Constructor Details
#initialize(app, options = {}) ⇒ MethodOverride
Returns a new instance of MethodOverride.
5 6 7 8 9 |
# File 'lib/jsonp/method_override.rb', line 5 def initialize(app, = {}) @app = app @callback_param = .fetch(:callback_param, "_callback") @method_param = .fetch(:method_param, "_method") end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jsonp/method_override.rb', line 11 def call(env) callback = Utils.extract_callback(env, @callback_param) method = Utils.extract_method(env, @method_param) if env["REQUEST_METHOD"] == "GET" && callback && method env["REQUEST_METHOD"] = method end @app.call(env) end |