Repository navigation
feat: Add rest.Catalog Option to provide custom http.RoundTripper - #552
Conversation
| type sessionTransport struct { | ||
| http.Transport | ||
|
|
||
| transport http.RoundTripper |
There was a problem hiding this comment.
what's the benefit to doing this?
There was a problem hiding this comment.
This allows alternate transports to be used, not just the builtin http.Transport implementation. In practice any real http.RoundTripper is going to wrap http.Transport at some level, but it opens up the ability to pass in a client with "middleware" such as instrumentation, added auth, etc without needing to handle it in this library's implementation. I added some context for why it's helpful in the linked issue.
There was a problem hiding this comment.
We can also embed the interface instead of making it into an unexported field, similar to how it was before. That change wasn't necessary. I just pushed that up.
| } | ||
| } | ||
|
|
||
| func WithCustomTransport(transport http.RoundTripper) Option { |
There was a problem hiding this comment.
Last nit: needs a docstring comment
There was a problem hiding this comment.
I added a docstring calling out the potential for this option to shadow WithTLSConfig, but also added a check to specifically report that condition and a test for it. Let me know what you think.
fixes: #551
Enables customization of the catalog's
http.Client.Transportvia thehttp.RoundTripperinterface. Technically certain existing options such asoptions.tlsConfigcould be achieved by specifying aoptions.transportwith that config set, but the option is left in for compatibility.