Sha256: 093feb674d52a23dac451de627d595b89df7d804ed7f35a495b893bb116a5aae

Contents?: true

Size: 830 Bytes

Versions: 22

Compression:

Stored size: 830 Bytes

Contents

module Timber
  module Integrations
    module Rack
      # Reponsible for adding the Session context for applications that use `Rack`.
      class SessionContext
        def initialize(app)
          @app = app
        end

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

        private
          def get_session_id(env)
            if env['rack.session']
              begin
                env['rack.session'].id
              rescue Exception
                nil
              end
            else
              nil
            end
          end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/integrations/rack/session_context.rb
timber-2.0.23 lib/timber/integrations/rack/session_context.rb
timber-2.0.22 lib/timber/integrations/rack/session_context.rb
timber-2.0.21 lib/timber/integrations/rack/session_context.rb
timber-2.0.20 lib/timber/integrations/rack/session_context.rb
timber-2.0.19 lib/timber/integrations/rack/session_context.rb
timber-2.0.17 lib/timber/integrations/rack/session_context.rb
timber-2.0.16 lib/timber/integrations/rack/session_context.rb
timber-2.0.15 lib/timber/integrations/rack/session_context.rb
timber-2.0.14 lib/timber/integrations/rack/session_context.rb
timber-2.0.12 lib/timber/integrations/rack/session_context.rb
timber-2.0.11 lib/timber/integrations/rack/session_context.rb
timber-2.0.10 lib/timber/integrations/rack/session_context.rb
timber-2.0.9 lib/timber/integrations/rack/session_context.rb
timber-2.0.8 lib/timber/integrations/rack/session_context.rb
timber-2.0.7 lib/timber/integrations/rack/session_context.rb
timber-2.0.6 lib/timber/integrations/rack/session_context.rb
timber-2.0.5 lib/timber/integrations/rack/session_context.rb
timber-2.0.4 lib/timber/integrations/rack/session_context.rb
timber-2.0.3 lib/timber/integrations/rack/session_context.rb