How gock mocks HTTP requests
mastergock operates by intercepting outgoing HTTP requests through the following lifecycle:
- Interception: It intercepts requests via
http.DefaultTransportor a customhttp.Transportused by anyhttp.Client. - Matching: It matches outgoing requests against a pool of defined mock expectations in FIFO (First-In-First-Out) declaration order.
- Resolution: If a mock matches, it is used to compose the mock HTTP response.
- Fallback: If no mock matches, the request resolves with an error, unless real networking mode is enabled, in which case a real HTTP request is performed.