Class: HttpClientGenerator::Plugs::SetRequestId
- Inherits:
-
Object
- Object
- HttpClientGenerator::Plugs::SetRequestId
- Defined in:
- lib/http_client_generator/plugs/set_request_id.rb
Instance Method Summary collapse
- #call(req) ⇒ Object
-
#initialize(header_name) ⇒ SetRequestId
constructor
A new instance of SetRequestId.
Constructor Details
#initialize(header_name) ⇒ SetRequestId
Returns a new instance of SetRequestId.
10 11 12 |
# File 'lib/http_client_generator/plugs/set_request_id.rb', line 10 def initialize(header_name) @header_name = header_name end |
Instance Method Details
#call(req) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/http_client_generator/plugs/set_request_id.rb', line 14 def call(req) request_id = req.rest_args[:request_id] || SecureRandom.uuid req.headers[@header_name] = request_id req.extra[:request_id] = request_id req end |