-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set custom http.RoundTripper
#65
Comments
@bak1an I need a time to analyze and get back to you. However your description makes sense. |
@bak1an I took longer than I expected to respond for your query. I would like to give you a background. Since
Now let's get back to your question, whether adding support for Looking forward to your thoughts. |
Let me take another look at this... |
Sure, I will wait for your inputs. |
Whenever you have inputs please let me know. Thanks. |
Existing timeout, TLS and proxy resty interfaces are looking simple and solid so we definitely should keep them around without making anything there harder to use. On the other hand, giving users ability to override The way to get this done I see at the moment is to provide users with And the proxy/timeout/tls methods stay with the same interface, they will just do type assertion on Does this sound sane? |
Yes it's sounds good. Thank you. |
@jeevatkm Then I will make a PR for this around the end of the week. Thanks! |
Implementation is in #91, closing it. |
At the moment it is not possible to set custom
http.RoundTripper
as a transport in resty since itstransport
field wants exactlyhttp.Transport
struct. On the contrary, golang's stdlib client allows us to use any RoundTripper - https://golang.org/src/net/http/client.go?s=1933:4055#L46Providing custom RoundTripper can be usable in testing, i.e. one could hijack transport to be provided by some mocking library (https://github.com/dnaeon/go-vcr) or when there is a need to use custom transport for whatever reasons like connecting to weird places with weird protocols or using transport with more features than golang's one provides (https://github.com/pkulak/simpletransport).
Resty is currently relying on
http.Transport
to provide a way for controlling proxies, tls and timeouts.We could use type assertion in those places to check if
RoundTripper
we have is anhttp.Transport
and do nothing in case it is not (or returning error). We could also mention it in the documentation that those things are controlled by underlying transport soSetProxy
,SetTimeout
andSetTLSClientConfig
won't function in case custom nonhttp.Transport
transport used.I can provide a pull request if you find the idea to be valid.
The text was updated successfully, but these errors were encountered: