Documentation
¶
Overview ¶
Package client make easy to use an http client
Index ¶
Constants ¶
View Source
const PrefixHTTP = "HTTP_"
PrefixHTTP is the env prefix of Config environment variables.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPClient ¶
NewHTTPClient crate a new *http.Client with Config fields set. If parent is present only config fields are changed.
Types ¶
type Config ¶
type Config struct {
Timeout time.Duration `env:"TIMEOUT,required"`
RoundtripperStatusCode []string `env:"ROUNDTRIPPER_STATUSCODE,default=2.."`
}
Config of the http client.
func (Config) SetTimeout ¶
SetTimeout set request timeout.
type HeaderTripper ¶ added in v1.0.0
type HeaderTripper struct {
http.RoundTripper
// contains filtered or unexported fields
}
HeaderTripper wrap http.RoundTripper to enrich with log. This way all outgoing requests (even bodies) will be logged.
func NewLogTripper ¶ added in v1.0.0
func NewLogTripper(parent http.RoundTripper, log log.Logger, acceptedStatusCodes []string) *HeaderTripper
NewLogTripper creates a new HeaderTripper using parent http.RoundTripper with log logger and will log responses bodies if no acceptedSatusCodes match (regex are accepted).
Click to show internal directories.
Click to hide internal directories.