Class: HttpMonkey::Middlewares::Cookie

Inherits:
Object
  • Object
show all
Defined in:
lib/http_monkey/middlewares/cookie.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Cookie

Returns a new instance of Cookie.


5
6
7
8
9
# File 'lib/http_monkey/middlewares/cookie.rb', line 5

def initialize(app, options = {})
  @app = app
  @store = options.fetch(:store, HttpMonkey::Cookie::MemoryStore.instance)
  @debug = options.fetch(:debug, false)
end

Instance Method Details

#call(env) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/http_monkey/middlewares/cookie.rb', line 11

def call(env)
  log "-> Cookie Middleware"

  retrieve_cookie(env)
  response = @app.call(env)
  store_cookie(env, response)

  log "<- Cookie Middleware"
  response
end