Documentation ¶
Overview ¶
Package clihttp adds opentracing support to http client.
Example ¶
client := NewClient(opentracing.GlobalTracer()) req, _ := http.NewRequest("GET", "https://example.com/", nil) resp, _ := client.Do(req) resp.Body.Close()
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Providers ¶ added in v0.10.3
func Providers(options ...ProvidersOptionFunc) di.Deps
Providers provides the http client as a dependency. Depends On:
opentracing.Tracer
Provides:
*clihttp.Client
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a http client that traces http requests.
type ClientArgs ¶ added in v0.10.3
type ClientArgs struct {
Populator contract.DIPopulator
}
ClientArgs is the constructor argument for WithClientConstructor. See WithClientConstructor for usage.
type Option ¶
type Option func(*Client)
Option changes the behavior of Client.
func WithRequestLogThreshold ¶
WithRequestLogThreshold is options that sets threshold of request logging in number of bytes. If the payload is larger than this threshold, the log will be omit.
func WithResponseLogThreshold ¶
WithResponseLogThreshold is options that sets threshold of response logging in number of bytes. If the response body is larger than this threshold, the log will be omit.
type ProvidersOptionFunc ¶ added in v0.10.3
type ProvidersOptionFunc func(options *providersOption)
ProvidersOptionFunc is the type of functional providersOption for Providers. Use this type to change how Providers work.
func WithClientConstructor ¶ added in v0.10.3
func WithClientConstructor(f func(args ClientArgs) (contract.HttpDoer, error)) ProvidersOptionFunc
WithClientConstructor instructs the Providers to accept an alternative constructor for the contract.HttpDoer to be wrapped by clihttp.NewClient.
func WithClientOption ¶ added in v0.10.3
func WithClientOption(options ...Option) ProvidersOptionFunc
WithClientOption instructs the Providers to accept additional options for the NewClient call, such as WithRequestLogThreshold.