Class: Makara::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/makara/middleware.rb

Constant Summary collapse

IDENTIFIER =
'_mkra_ctxt'

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



14
15
16
# File 'lib/makara/middleware.rb', line 14

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/makara/middleware.rb', line 19

def call(env)

  return @app.call(env) if ignore_request?(env)

  Makara::Context.set_previous previous_context(env)
  Makara::Context.set_current new_context(env)

  status, headers, body = @app.call(env)

  store_context(status, headers)

  [status, headers, body]
end