class Rack::MethodOverride
Константы
- ALLOWED_METHODS
- HTTP_METHODS
- HTTP_METHOD_OVERRIDE_HEADER
- METHOD_OVERRIDE_PARAM_KEY
Открытые методы класса
# File lib/rack/method_override.rb, line 23 def initialize(app, allowed_methods: PRIV_ALLOWED_METHODS, allowed_overrides: PRIV_HTTP_METHODS) @app = app @allowed_methods = allowed_methods @allowed_overrides = allowed_overrides end
Открытые методы экземпляра
# File lib/rack/method_override.rb, line 29
def call(env)
if allowed_methods.include?(env[REQUEST_METHOD])
method = method_override(env)
if allowed_overrides.include?(method)
env[RACK_METHODOVERRIDE_ORIGINAL_METHOD] = env[REQUEST_METHOD]
env[REQUEST_METHOD] = method
end
end
@app.call(env)
end # File lib/rack/method_override.rb, line 41
def method_override(env)
req = Request.new(env)
method = method_override_param(req) ||
env[HTTP_METHOD_OVERRIDE_HEADER]
begin
method.to_s.upcase
rescue ArgumentError
env[RACK_ERRORS].puts "Invalid string for method"
end
end
© 2007-2021 Leah Neukirchen
Licensed under the MIT License.