You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking at how to wrap the client's Transport, for example to apply an auth token middleware at the HTTP level. With a normal http.Client, I would usually reassign it like this
Would it make sense to keep a pointer to the original transport alongside Transport to allow wrapping the later with I guess conventional patterns? Or alternatively, add a client option to wrap Transport in a similar way?
@anuraaga, thanks for bringing attention to this. The way it would have to be done currently is to actually make a copy of the embedded client, mutate its transport field, and then use that client copy instead of the original embedded one. You may still need to keep a reference to the original *httplb.Client, just to close it (even though it's not what is directly being used for HTTP calls).
But I just opened #79 to make this more intuitive, so you can use the same technique you'd usually use to wrap the transport with middleware.
Activity
jhump commentedon Apr 28, 2025
@anuraaga, thanks for bringing attention to this. The way it would have to be done currently is to actually make a copy of the embedded client, mutate its transport field, and then use that client copy instead of the original embedded one. You may still need to keep a reference to the original
*httplb.Client, just to close it (even though it's not what is directly being used for HTTP calls).But I just opened #79 to make this more intuitive, so you can use the same technique you'd usually use to wrap the transport with middleware.