Documentation
¶
Overview ¶
Package transport provides HTTP transport middleware for logging, recording, and other cross-cutting concerns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTransport ¶
func NewTransport(tracer trace.Tracer, next http.RoundTripper) http.RoundTripper
NewTransport returns an http.RoundTripper that creates an OpenTelemetry client span for every HTTP request, including OAuth token refresh calls and redirect hops. It wraps next, falling back to http.DefaultTransport when next is nil.
Use this with client.Client.Transport to ensure all HTTP calls — including those made by golang.org/x/oauth2 during token refresh — are traced:
httpClient.Transport = transport.NewTransport(tracer, httpClient.Transport)
Types ¶
type Logging ¶
type Logging struct {
http.RoundTripper
// contains filtered or unexported fields
}
Logging is an http.RoundTripper middleware that logs requests and responses.
func NewLogging ¶
NewLogging creates a logging middleware that wraps parent. Every request and response is written to w. When verbose is true the request and response bodies are also written. If parent is nil, http.DefaultTransport is used.
type Recorder ¶
type Recorder struct {
http.RoundTripper
// contains filtered or unexported fields
}
Recorder is an http.RoundTripper middleware that captures the status code and response headers of the most recent response. It is safe for concurrent use; each RoundTrip call overwrites the previously recorded values.
func NewRecorder ¶
func NewRecorder(parent http.RoundTripper) *Recorder
NewRecorder wraps parent in a Recorder. If parent is nil, http.DefaultTransport is used.
func (*Recorder) Header ¶
Header returns a copy of the response headers recorded from the most recent response, or nil if no response has been received yet.
func (*Recorder) Reset ¶
func (r *Recorder) Reset()
Reset clears the recorded status code and headers.
func (*Recorder) RoundTrip ¶
RoundTrip implements http.RoundTripper, recording the response status and headers before returning the response to the caller.
func (*Recorder) StatusCode ¶
StatusCode returns the HTTP status code recorded from the most recent response, or 0 if no response has been received yet.