Class: Tailog::RequestId

Inherits:
Object
  • Object
show all
Defined in:
lib/tailog/request_id.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RequestId

Returns a new instance of RequestId.



3
4
5
# File 'lib/tailog/request_id.rb', line 3

def initialize app
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
# File 'lib/tailog/request_id.rb', line 7

def call env
  Tailog.request_id = external_request_id(env) || internal_request_id
  @app.call(env).tap do |_status, headers, _body|
    headers["X-Request-Id"] = Tailog.request_id
  end
end