Documentation / guides
Context cancellation
Propagate caller cancellation through authorization, HTTP setup, body reads, and streams.
The caller’s context is the cancellation authority. The transport binds it to the request before authorization and HTTP execution; stream consumption stays bound to the same request context.
Invoke
InvokeWithAuth checks binding, model validity, authorizer presence, route and
encoding, call-scoped authorization, HTTP, and bounded body reads in order.
Cancellation during a call-scoped authorizer returns the credentials/httpauth
typed cancellation; the legacy Invoke wrapper preserves its historical
NetworkError conversion for compatibility.
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
response, err := client.Invoke(ctx, req)
if errors.Is(err, context.Canceled) {
return err
}
_ = response
Stream
Stream cancellation can stop connection setup or a later Next call. Once a
reader is returned, the retry decorator does not re-establish it after a
mid-stream cancellation or provider error. Call Close to release the body;
it is safe even when cancellation already interrupted a read.
Source and proof
Run go test ./transport ./stream.