Sha256: 9870d6179ab07dc3bfe71153837f0a5e40a2f7ed9aca019a36faf7e7fbabbb5c

Contents?: true

Size: 748 Bytes

Versions: 8

Compression:

Stored size: 748 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(
            host: request.host,
            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

8 entries across 8 versions & 1 rubygems

Version Path
timber-2.6.2 lib/timber/integrations/rack/http_context.rb
timber-2.6.1 lib/timber/integrations/rack/http_context.rb
timber-2.6.0 lib/timber/integrations/rack/http_context.rb
timber-2.6.0.pre.beta2 lib/timber/integrations/rack/http_context.rb
timber-2.6.0.pre.beta1 lib/timber/integrations/rack/http_context.rb
timber-2.5.1 lib/timber/integrations/rack/http_context.rb
timber-2.5.0 lib/timber/integrations/rack/http_context.rb
timber-2.4.0 lib/timber/integrations/rack/http_context.rb