class Praxis::MiddlewareApp

Attributes

target[R]

Public Class Methods

for( **args ) click to toggle source

Initialize the application instance with the desired args, and return the wrapping class.

# File lib/praxis/middleware_app.rb, line 7
def self.for( **args )
  Praxis::Application.instance.setup(**args)
  self
 end
new( inner ) click to toggle source
# File lib/praxis/middleware_app.rb, line 12
def initialize( inner )
  @target = inner
end

Public Instance Methods

call(env) click to toggle source
# File lib/praxis/middleware_app.rb, line 16
def call(env)
  result = Praxis::Application.instance.call(env)

  unless ( [404,405].include?(result[0].to_i) && result[1]['X-Cascade'] == 'pass' )
    # Respect X-Cascade header if it doesn't specify 'pass'
    result
  else
    last_body = result[2]
    last_body.close if last_body.respond_to? :close
    target.call(env)
  end
end