Class: Makara::Middleware

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

Constant Summary collapse

IDENTIFIER =
'_mkra_ctxt'
{
  :path => '/',
  :http_only => true,
  :max_age => '5'
}

Instance Method Summary collapse

Constructor Details

#initialize(app, cookie_options = {}) ⇒ Middleware

Returns a new instance of Middleware.



19
20
21
22
# File 'lib/makara/middleware.rb', line 19

def initialize(app, cookie_options = {})
  @app = app
  @cookie = DEFAULT_COOKIE.merge(cookie_options)
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/makara/middleware.rb', line 25

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