Sha256: 351f5e07914e032713fcfbb2626fa1f2b48451bb8cca8225eff296de76f59bd1

Contents?: true

Size: 716 Bytes

Versions: 24

Compression:

Stored size: 716 Bytes

Contents

require "timber/contexts/http"
require "timber/current_context"
require "timber/integrations/rack/middleware"
require "timber/util"

module Timber
  module Integrations
    module Rack
      # A Rack middleware that is reponsible for adding the HTTP context {Timber::Contexts::HTTP}.
      class HTTPContext < Middleware
        def call(env)
          request = Util::Request.new(env)
          context = Contexts::HTTP.new(
            method: request.request_method,
            path: request.path,
            remote_addr: request.ip,
            request_id: request.request_id
          )
          CurrentContext.with(context) do
            @app.call(env)
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
timber-2.3.4 lib/timber/integrations/rack/http_context.rb
timber-2.3.3 lib/timber/integrations/rack/http_context.rb
timber-2.3.2 lib/timber/integrations/rack/http_context.rb
timber-2.3.1 lib/timber/integrations/rack/http_context.rb
timber-2.3.0 lib/timber/integrations/rack/http_context.rb
timber-2.2.3 lib/timber/integrations/rack/http_context.rb
timber-2.2.2 lib/timber/integrations/rack/http_context.rb
timber-2.2.1 lib/timber/integrations/rack/http_context.rb
timber-2.2.0 lib/timber/integrations/rack/http_context.rb
timber-2.1.10 lib/timber/integrations/rack/http_context.rb
timber-2.1.9 lib/timber/integrations/rack/http_context.rb
timber-2.1.8 lib/timber/integrations/rack/http_context.rb
timber-2.1.7 lib/timber/integrations/rack/http_context.rb
timber-2.1.6 lib/timber/integrations/rack/http_context.rb
timber-2.1.5 lib/timber/integrations/rack/http_context.rb
timber-2.1.4 lib/timber/integrations/rack/http_context.rb
timber-2.1.3 lib/timber/integrations/rack/http_context.rb
timber-2.1.2 lib/timber/integrations/rack/http_context.rb
timber-2.1.1 lib/timber/integrations/rack/http_context.rb
timber-2.1.0 lib/timber/integrations/rack/http_context.rb