Class: Rack::CheckHttpMethodAllowed
- Inherits:
-
Object
- Object
- Rack::CheckHttpMethodAllowed
- Defined in:
- lib/rack/check_http_method_allowed.rb,
lib/rack/check_http_method_allowed/version.rb
Constant Summary collapse
- RFC2616 =
%w(OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT)
- RFC5789 =
%w(PATCH)
- DEFAULT =
RFC2616 + RFC5789
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, allowed_methods = nil) ⇒ CheckHttpMethodAllowed
constructor
A new instance of CheckHttpMethodAllowed.
Constructor Details
#initialize(app, allowed_methods = nil) ⇒ CheckHttpMethodAllowed
Returns a new instance of CheckHttpMethodAllowed.
10 11 12 13 |
# File 'lib/rack/check_http_method_allowed.rb', line 10 def initialize(app, allowed_methods=nil) @app = app @allowed_methods = allowed_methods || DEFAULT end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rack/check_http_method_allowed.rb', line 15 def call(env) if method_not_allowed?(env['REQUEST_METHOD']) reject_request(env) else @app.call(env) end end |