Module: Roda::RodaPlugins::Middleware::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#_roda_run_main_route(r) ⇒ Object

Override the route block so that if no route matches, we throw so that the next middleware is called.



203
204
205
206
207
208
209
210
# File 'lib/roda/plugins/middleware.rb', line 203

def _roda_run_main_route(r)
  res = super
  if r.forward_next
    r.env['roda.response_headers'] = response.headers if opts[:middleware_forward_response_headers]
    throw :next, true
  end
  res
end

#call(&block) ⇒ Object

Override the route block so that if no route matches, we throw so that the next middleware is called. Old Dispatch API.



190
191
192
193
194
195
196
197
198
199
# File 'lib/roda/plugins/middleware.rb', line 190

def call(&block)
  super do |r|
    res = instance_exec(r, &block) # call Fallback
    if r.forward_next
      r.env['roda.response_headers'] = response.headers if opts[:middleware_forward_response_headers]
      throw :next, true
    end
    res
  end
end