I am trying to understand in what cases would it make sense to
implement my own RoundTripper.

If I search about it, I come across examples of RoundTripper that try
to do things like caching, retries, authentication, etc. I also read
somewhere that there are many RoundTripper implementations that just
set the User-Agent header on a request.

I know that the documentation says "RoundTrip should not attempt to
handle higher-level protocol details such as redirects,
authentication, or cookies." And, I also understand that RoundTripper
would be a bad place for things like caching.

However, I am not able to figure out why is it such a bad idea to use
RoundTripper as a middleware that allows me to do some of the higher
level things like authentication. After all, authentication is just
about interpreting and/or manipulating some headers. In some cases, it
could be just as good as setting the User-Agent where all that happens
is setting the Authorization header with a token. In some other cases,
it could mean interpreting the challenge thrown by the server and then
making the same call again with a response to the challenge.

Can someone please help me understand this better?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABnk5p0k77he6c7Pw0APQJF%2B_FDJFOFdJp_BJ8eS66jbw6%3DG1w%40mail.gmail.com.

Reply via email to