# class Rack::Utils::Context

`Context` allows the use of a compatible middleware at different points in a request handling stack. A compatible middleware must define `context` which should take the arguments env and app. The first of which would be the request environment. The second of which would be the rack application that the request would be forwarded to.

### Attributes

app[R]
for[R]

### Public Class Methods

new(app_f, app_r) click to toggle source

    # File lib/rack/utils.rb, line 444
    def initialize(app_f, app_r)
      raise 'running context does not respond to #context' unless app_f.respond_to? :context
      @for, @app = app_f, app_r
    end

### Public Instance Methods

call(env) click to toggle source

    # File lib/rack/utils.rb, line 449
    def call(env)
      @for.context(env, @app)
    end

context(env, app = @app) click to toggle source

    # File lib/rack/utils.rb, line 457
    def context(env, app = @app)
      recontext(app).call(env)
    end

recontext(app) click to toggle source

    # File lib/rack/utils.rb, line 453
    def recontext(app)
      self.class.new(@for, app)
    end