Class: HttpClientGenerator::Plugs::SetRequestId

Inherits:
Object
  • Object
show all
Defined in:
lib/http_client_generator/plugs/set_request_id.rb

Instance Method Summary collapse

Constructor Details

#initialize(header_name) ⇒ SetRequestId

Returns a new instance of SetRequestId.



8
9
10
# File 'lib/http_client_generator/plugs/set_request_id.rb', line 8

def initialize(header_name)
  @header_name = header_name
end

Instance Method Details

#call(req) ⇒ Object



12
13
14
15
# File 'lib/http_client_generator/plugs/set_request_id.rb', line 12

def call(req)
  req.headers[@header_name] = req.rest_args[:request_id] || SecureRandom.uuid
  req
end