Class: Hanami::Router::NotAllowedError
- Inherits:
-
Error
- Object
- Error
- Hanami::Router::NotAllowedError
- Defined in:
- lib/hanami/extensions/router/errors.rb
Overview
Error raised when a request is made for a route using a HTTP method not allowed on the route.
Raised only when using hanami-router as part of a full Hanami app. When using hanami-router standalone, the behavior for such requests is to return a “Method Not Allowed” response.
Instance Attribute Summary collapse
-
#allowed_methods ⇒ Array<String>
readonly
The allowed methods for the route.
-
#env ⇒ Hash
readonly
The Rack environment for the request.
Instance Method Summary collapse
-
#initialize(env, allowed_methods) ⇒ NotAllowedError
constructor
A new instance of NotAllowedError.
Constructor Details
#initialize(env, allowed_methods) ⇒ NotAllowedError
Returns a new instance of NotAllowedError.
49 50 51 52 53 54 55 |
# File 'lib/hanami/extensions/router/errors.rb', line 49 def initialize(env, allowed_methods) @env = env @allowed_methods = allowed_methods = "Only #{allowed_methods.join(', ')} requests are allowed at #{env["PATH_INFO"]}" super() end |
Instance Attribute Details
#allowed_methods ⇒ Array<String> (readonly)
Returns the allowed methods for the route.
47 48 49 |
# File 'lib/hanami/extensions/router/errors.rb', line 47 def allowed_methods @allowed_methods end |
#env ⇒ Hash (readonly)
Returns the Rack environment for the request.
41 42 43 |
# File 'lib/hanami/extensions/router/errors.rb', line 41 def env @env end |