Sha256: 3729b7cc6c29a5d88ac67e8559488e8307258cd244f8995312f4ea78ed8a86f3

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

require "timber/integrations/rack/middleware"

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

2 entries across 2 versions & 1 rubygems

Version Path
timber-2.1.0.rc2 lib/timber/integrations/rack/http_context.rb
timber-2.1.0.rc1 lib/timber/integrations/rack/http_context.rb