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

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

Overview

A Rack middleware that is reponsible for adding the HTTP context Contexts::HTTP.

Instance Method Summary collapse

Methods inherited from Middleware

enabled=, enabled?, #initialize

Constructor Details

This class inherits a constructor from Timber::Integrations::Rack::Middleware

Instance Method Details

#call(env) ⇒ Object



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

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.add(context.to_hash)
  @app.call(env)
end