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.



206
207
208
209
210
211
212
213
# File 'lib/roda/plugins/middleware.rb', line 206

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.



193
194
195
196
197
198
199
200
201
202
# File 'lib/roda/plugins/middleware.rb', line 193

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