http.RoundTripper
The Go interface for the part of an HTTP client that actually sends one request and returns one response.
In more detail
An http.Client delegates to its Transport, which is a RoundTripper. Swapping in a fake one lets tests return fixed responses with no network. The default transport pools and reuses connections.
Example
client := &http.Client{Transport: fake{}}Related terms
- http.Client — The Go type that sends HTTP requests and returns responses, managing connections and timeouts for you.
- test double — Any object that replaces a real dependency in a test: a stub returns canned data, a fake is a small working implementation, and a mock checks interactions.
- interface — A named set of member signatures that a type promises to implement, with no state of its own.
- deterministic — Always producing the same result from the same inputs, with nothing left to chance or timing.
Taught in
- Calling APIs with net/http Client — Concurrent Systems Programming with Go