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 ¶
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 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 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.