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.



157
158
159
160
161
162
163
164
# File 'lib/roda/plugins/middleware.rb', line 157

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.



144
145
146
147
148
149
150
151
152
153
# File 'lib/roda/plugins/middleware.rb', line 144

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