Class: Timber::Integrations::Rack::HTTPContext

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

Overview

Reponsible for adding the HTTP context for applications that use ‘Rack`.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ HTTPContext

Returns a new instance of HTTPContext.



6
7
8
# File 'lib/timber/integrations/rack/http_context.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/timber/integrations/rack/http_context.rb', line 10

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