class Roda::RodaPlugins::Middleware::Forwarder
Forwarder instances are what is actually used as middleware.
def call(env)
If this returns a result, return that result directly. Otherwise,
When calling the middleware, first call the current middleware.
def call(env) res = nil call_next = catch(:next) do env[@mid.opts[:middleware_env_var]] = true res = @mid.call(env) false end if call_next res = @app.call(env) end if handle_result = @mid.opts[:middleware_handle_result] handle_result.call(env, res) end res end
def initialize(mid, app, *args, &block)
Make a subclass of +mid+ to use as the current middleware,
def initialize(mid, app, *args, &block) @mid = Class.new(mid) if configure = @mid.opts[:middleware_configure] configure.call(@mid, *args, &block) elsif block || !args.empty? raise RodaError, "cannot provide middleware args or block unless loading middleware plugin with a block" end @app = app end