@@ -87,6 +87,8 @@ class Client
87
87
#
88
88
# @option api_key [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and `api_key`
89
89
# joined by a colon as a String, or a hash with the `id` and `api_key` values.
90
+ # @option opaque_id_prefix [String] :opaque_id_prefix set a prefix for X-Opaque-Id when initializing the client. This
91
+ # will be prepended to the id you set before each request if you're using X-Opaque-Id
90
92
#
91
93
# @yield [faraday] Access and configure the `Faraday::Connection` instance directly with a block
92
94
#
@@ -114,6 +116,7 @@ def initialize(arguments={}, &block)
114
116
DEFAULT_HOST )
115
117
116
118
@send_get_body_as = @arguments [ :send_get_body_as ] || 'GET'
119
+ @opaque_id_prefix = @arguments [ :opaque_id_prefix ] || nil
117
120
118
121
if @arguments [ :request_timeout ]
119
122
@arguments [ :transport_options ] [ :request ] = { timeout : @arguments [ :request_timeout ] }
@@ -148,7 +151,8 @@ def perform_request(method, path, params = {}, body = nil, headers = nil)
148
151
method = @send_get_body_as if 'GET' == method && body
149
152
if @opaque_id
150
153
headers = { } if headers . nil?
151
- headers . merge! ( 'X-Opaque-Id' => @opaque_id )
154
+ opaque_id = @opaque_id_prefix ? "#{ @opaque_id_prefix } #{ @opaque_id } " : @opaque_id
155
+ headers . merge! ( 'X-Opaque-Id' => opaque_id )
152
156
@opaque_id = nil # Remove Opaque id after each request
153
157
end
154
158
transport . perform_request ( method , path , params , body , headers )
0 commit comments