Methods
C
M
N
Constants
HTTP_METHODS = %w[GET HEAD PUT POST DELETE OPTIONS PATCH LINK UNLINK]
 
METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
 
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
 
ALLOWED_METHODS = %w[POST]
 
Class Public methods
new(app)
# File lib/rack/method_override.rb, line 9
def initialize(app)
  @app = app
end
Instance Public methods
call(env)
# File lib/rack/method_override.rb, line 13
def call(env)
  if allowed_methods.include?(env[REQUEST_METHOD])
    method = method_override(env)
    if HTTP_METHODS.include?(method)
      env[RACK_METHODOVERRIDE_ORIGINAL_METHOD] = env[REQUEST_METHOD]
      env[REQUEST_METHOD] = method
    end
  end

  @app.call(env)
end
method_override(env)
# File lib/rack/method_override.rb, line 25
def method_override(env)
  req = Request.new(env)
  method = method_override_param(req) ||
    env[HTTP_METHOD_OVERRIDE_HEADER]
  method.to_s.upcase
end