Class: GoogleCloudRun::RequestId

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RequestId

Returns a new instance of RequestId.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
# File 'lib/google_cloud_run/request_id.rb', line 10

def call(env)
  req = ActionDispatch::Request.new env
  trace, _, _ = GoogleCloudRun.parse_trace_context(req.headers["X-Cloud-Trace-Context"])
  @app.call(env).tap { |_status, headers, _body| headers["X-Request-Id"] = trace }
end