Allow incremental addition of HTTP headers to generated Go clients #5458
Labels
feature
Requests for new features.
product/sdk-generator
Fern's SDK Generator that outputs client libraries in 7 languages
Feature Description
We have two different auth mechanisms for our API: one uses a bearer token and one uses basic auth.
I was confused recently as to why some requests weren't coming through with the HTTP User-Agent I was configuring. Then I realized that it was because the
option.WithHTTPHeader
stomps on previously set headers.For example, constructing a client with the following:
Replaces the user agent with the authorization. (This is slightly more obvious in this example; in my case I had a function that was applying the "base" options ---use, user-agent -- and appending the passed in auth option(s)).
I think it'd be clearer to if
WithHTTPHeader
was additive, with aoption.WithHTTPHeaders
(plural) that does the current behavior. Since changing the semantics may be tricky, perhaps anAddHTTPHeader
is a reasonable name for an additive case.Proposed Generated Code (Optional)
The text was updated successfully, but these errors were encountered: