Module: Roda::RodaPlugins::Middleware::ClassMethods
- Defined in:
- lib/roda/plugins/middleware.rb
Instance Method Summary collapse
-
#new(app) ⇒ Object
Create a Forwarder instead of a new instance if a non-Hash is given.
-
#route(*args, &block) ⇒ Object
Override the route block so that if no route matches, we throw so that the next middleware is called.
Instance Method Details
#new(app) ⇒ Object
Create a Forwarder instead of a new instance if a non-Hash is given.
67 68 69 70 71 72 73 |
# File 'lib/roda/plugins/middleware.rb', line 67 def new(app) if app.is_a?(Hash) super else Forwarder.new(self, app) end end |
#route(*args, &block) ⇒ Object
Override the route block so that if no route matches, we throw so that the next middleware is called.
77 78 79 80 81 82 83 |
# File 'lib/roda/plugins/middleware.rb', line 77 def route(*args, &block) super do |r| res = instance_exec(r, &block) throw :next, true if r.forward_next res end end |