Class Rack::MethodOverride
In: lib/rack/methodoverride.rb
Parent: Object

Methods

call   new  

Constants

HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS)
METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze

Public Class methods

[Source]

    # File lib/rack/methodoverride.rb, line 8
 8:     def initialize(app)
 9:       @app = app
10:     end

Public Instance methods

[Source]

    # File lib/rack/methodoverride.rb, line 12
12:     def call(env)
13:       if env["REQUEST_METHOD"] == "POST"
14:         req = Request.new(env)
15:         method = req.POST[METHOD_OVERRIDE_PARAM_KEY] ||
16:           env[HTTP_METHOD_OVERRIDE_HEADER]
17:         method = method.to_s.upcase
18:         if HTTP_METHODS.include?(method)
19:           env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
20:           env["REQUEST_METHOD"] = method
21:         end
22:       end
23: 
24:       @app.call(env)
25:     end

[Validate]