Documentation ¶
Overview ¶
Package httpclient provides a configurable and instrumented HTTP client with common options. It includes a trace ID header support and common logging capabilities, including the ability to dump the redacted request and response messages.
Index ¶
- type Client
- type DialContextFunc
- type InstrumentRoundTripper
- type Option
- func WithComponent(name string) Option
- func WithDialContext(fn DialContextFunc) Option
- func WithLogPrefix(prefix string) Option
- func WithRedactFn(fn RedactFn) Option
- func WithRoundTripper(fn InstrumentRoundTripper) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTraceIDHeaderName(name string) Option
- type RedactFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the default HTTP client functionalities and adds logging and instrumentation capabilities.
type DialContextFunc ¶ added in v1.82.0
DialContextFunc is an alias for a net.Dialer.DialContext function.
type InstrumentRoundTripper ¶
type InstrumentRoundTripper func(next http.RoundTripper) http.RoundTripper
InstrumentRoundTripper is an alias for a RoundTripper function.
type Option ¶
type Option func(c *Client)
Option is the interface that allows to set client options.
func WithComponent ¶
WithComponent sets the component name to be used in logs.
func WithDialContext ¶ added in v1.82.0
func WithDialContext(fn DialContextFunc) Option
WithDialContext sets the DialContext function for the HTTP client. The DialContext function is used to establish network connections. It allows customizing the behavior of the client's underlying transport.
func WithLogPrefix ¶
WithLogPrefix specifies a string prefix to be added to each log field name in the Do method.
func WithRedactFn ¶
WithRedactFn set the function used to redact HTTP request and response dumps in the logs.
func WithRoundTripper ¶
func WithRoundTripper(fn InstrumentRoundTripper) Option
WithRoundTripper wraps the HTTP client Transport with the specified RoundTripper function.
func WithTimeout ¶
WithTimeout overrides the default client timeout.
func WithTraceIDHeaderName ¶
WithTraceIDHeaderName sets the trace id header name.