Class: Shamu::Rack::CookiesMiddleware

Inherits:
Object
  • Object
show all
Includes:
Scorpion::Rack
Defined in:
lib/shamu/rack/cookies_middleware.rb

Overview

Expose a Cookies hash to any service that wants to use session specific storage.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CookiesMiddleware

Returns a new instance of CookiesMiddleware.



11
12
13
# File 'lib/shamu/rack/cookies_middleware.rb', line 11

def initialize( app )
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/shamu/rack/cookies_middleware.rb', line 15

def call( env )
  cookies = Shamu::Rack::Cookies.new( env )
  scorpion( env ).hunt_for Shamu::Rack::Cookies, return: cookies

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

  [ status, cookies.apply!( headers ), body ]
end