Module: Roda::RodaPlugins::Middleware::ClassMethods

Defined in:
lib/roda/plugins/middleware.rb

Instance Method Summary collapse

Instance Method Details

#new(app = nil) ⇒ Object

If an argument is given, this is a middleware app, so create a Forwarder. Otherwise, this is a usual instance creation, so call super.



67
68
69
70
71
72
73
# File 'lib/roda/plugins/middleware.rb', line 67

def new(app=nil)
  if app
    Forwarder.new(self, app)
  else
    super()
  end
end

#route(&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
# File 'lib/roda/plugins/middleware.rb', line 77

def route(&block)
  super do |r|
    instance_exec(r, &block)
    throw :next, true
  end
end