Class: Routemaster::Middleware::RootPostOnly
- Inherits:
-
Object
- Object
- Routemaster::Middleware::RootPostOnly
- Defined in:
- lib/routemaster/middleware/root_post_only.rb
Overview
Rejects all requests but POST to the root path
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _options = {}) ⇒ RootPostOnly
constructor
A new instance of RootPostOnly.
Constructor Details
#initialize(app, _options = {}) ⇒ RootPostOnly
Returns a new instance of RootPostOnly.
5 6 7 |
# File 'lib/routemaster/middleware/root_post_only.rb', line 5 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 |
# File 'lib/routemaster/middleware/root_post_only.rb', line 9 def call(env) return [404, {}, []] unless ['', '/'].include? env['PATH_INFO'] return [405, {}, []] if env['REQUEST_METHOD'] != 'POST' @app.call(env) end |