jarcoal / httpmock

HTTP mocking for Golang
http://godoc.org/github.com/jarcoal/httpmock
MIT License
1.93k stars 103 forks source link

http.DefaultTransport is hardcoded #9

Closed panamafrancis closed 5 years ago

panamafrancis commented 9 years ago

http.DefaultTransport is hardcoded, this prevents httpmock from being used with some libraries like appengine/urlfetch which doesn't use http.DefaultTransport.

gabrielf commented 8 years ago

We use httpmock when testing appengine. We create a MockTransport using https://godoc.org/github.com/jarcoal/httpmock#NewMockTransport and then we put it in the context.Context and have some wrapper code that extracts a client from the context. If a MockTransport has been added it is used if not the default client from appengine is used.

Works like a charm! However it is necessary to use the new, go gettable, appengine packages.

dlebech commented 7 years ago

@panamafrancis Is this issue still unresolved for you?

panamafrancis commented 7 years ago

I've moved on and no longer work on AppEngine, but i'm guessing this would still affect appengine users. however the comment 2 above looks like a reasonable workaround.

for reference #10 was the PR

maxatome commented 5 years ago

Seems this issue won't progress now. Please comment or re-open if the solution of @gabrielf is not OK.