Class: AARRR::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



4
5
6
# File 'lib/aarrr/middleware.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/aarrr/middleware.rb', line 8

def call(env)
  aarrr_session = AARRR(env)

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

  # sets a tracking cookie on the response
  response = Rack::Response.new body, status, headers
  aarrr_session.save(response)

  response.finish
end