Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRoundTripper ¶
func NewRoundTripper(t *Transport) http.RoundTripper
NewRoundTripper creates an http.RoundTripper from a set of Transport options. If the Transport is nil, this function returns a default http.Transport instance. Otherwise, an http.Transport is returned with its fields set from the given Transport options.
func NewTlsConfig ¶
NewTlsConfig assembles a *tls.Config for clients given a set of configuration options. If the Tls options is nil, this method returns nil, nil.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is a sequence of Constructors, just like github.com/justinas/alice.Chain
func NewChain ¶
func NewChain(c ...Constructor) Chain
func (Chain) Append ¶
func (ch Chain) Append(more ...Constructor) Chain
func (Chain) Then ¶
func (ch Chain) Then(rt http.RoundTripper) http.RoundTripper
func (Chain) ThenFunc ¶
func (ch Chain) ThenFunc(rtf RoundTripperFunc) http.RoundTripper
type ChainFactory ¶ added in v0.0.3
A ChainFactory can be used to tailor a Chain of decorators for a specific client. This factory type is primarily useful when an application has multiple HTTP client objects. For cases where there is only (1) HTTP client, a Chain component works better.
type ChainFactoryFunc ¶ added in v0.0.3
func (ChainFactoryFunc) NewClientChain ¶ added in v0.0.3
func (cff ChainFactoryFunc) NewClientChain(name string, o Options) (Chain, error)
type ClientUnmarshalIn ¶
type ClientUnmarshalIn struct { fx.In // Unmarshaller is the required configuration unmarshalling component Unmarshaller config.Unmarshaller // Chain is an optional component. If present in the application, this chain // will be used to decorate the roundtripper. Any constructors set via Unmarshal // will be appended to this chain. This field and ChainFactory can be used together, and both // will be used to produce a merged Chain if both fields are set. // // Using this component allows for global decorators that apply to all clients. Chain Chain `optional:"true"` // ChainFactory is an optional component used to create a Chain specific to a given HTTP client. // Both this field and Chain may be set, in which case both are used to create a single Chain. ChainFactory ChainFactory `optional:"true"` // RoundTripper is an optional http.RoundTripper component. If present, this field will be used // for clients unmarshalled by this instance. Configuration will be ignored in favor of this component. RoundTripper http.RoundTripper `optional:"true"` }
ClientUnmarshalIn defines the set of dependencies for an HTTP client
type Constructor ¶
type Constructor func(http.RoundTripper) http.RoundTripper
Constructor is an Alice-style constructor for RoundTrippers
type Interface ¶
Interface defines the behavior of an HTTP client. *http.Client implements this interface.
type Options ¶
type Options struct { // Timeout is the http.Client timeout Timeout time.Duration // Header is an optional set of HTTP headers applied to all outgoing requests // made through any client created with these options. Header http.Header // Transport describes the http.Transport created for this client when a custom // RoundTripper is not supplied. If this is unset, a default http.Transport is created. Transport *Transport }
Options represents the set of configurable options for an HTTP client
type RequestHeaders ¶
RequestHeaders provides a RoundTripper constructor that inserts a constant set of headers into each request
func (RequestHeaders) Then ¶
func (rh RequestHeaders) Then(next http.RoundTripper) http.RoundTripper
func (RequestHeaders) ThenFunc ¶
func (rh RequestHeaders) ThenFunc(next RoundTripperFunc) http.RoundTripper
type RoundTripperFunc ¶
type Tls ¶
type Tls struct {
InsecureSkipVerify bool
}
Tls represents the set of configurable options for client-side TLS
type Transport ¶
type Transport struct { DisableKeepAlives bool DisableCompression bool MaxIdleConns int MaxIdleConnsPerHost int MaxConnsPerHost int IdleConnTimeout time.Duration ResponseHeaderTimeout time.Duration ExpectContinueTimeout time.Duration MaxResponseHeaderBytes int64 TlsHandshakeTimeout time.Duration Tls *Tls }
Transport represents the set of configurable options for a client RoundTripper The majority of these fields map directory to an http.Transport. See https://godoc.org/net/http#Transport
type Unmarshal ¶
type Unmarshal struct { // Key is the required configuration key unmarshalled via Viper. This key is unmarshalled as an Options. Key string // Name is the optional name of this client within the application. If unset, the Key is used. This // field is used when providing a named client component via Annotated. Name string // Chain is an optional decoration for the client's RoundTripper. This field is used for decoration // initialized outside the uber/fx application. Chain Chain }
Unmarshal encompasses all the non-component information for unmarshalling and instantiating an HTTP client.
func (Unmarshal) Annotated ¶ added in v0.0.3
Annotated returns an uber/fx Annotated instance that emits an HTTP client with a specific name. The Name field is used if set, otherwise Key is used. If multiple HTTP clients are needed for the enclosing application, use this function to emit them as named components.