Class: Timber::Integrations::Rack::SessionContext

Inherits:
Middleware
  • Object
show all
Defined in:
lib/timber/integrations/rack/session_context.rb

Overview

A Rack middleware that is responsible for adding the Session context Contexts::Session.

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Timber::Integrations::Rack::Middleware

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/timber/integrations/rack/session_context.rb', line 16

def call(env)
  id = get_session_id(env)
  if id
    context = Contexts::Session.new(id: id)
    CurrentContext.with(context) do
      @app.call(env)
    end
  else
    @app.call(env)
  end
end