Documentation
¶
Overview ¶
Package clients is a set of utilities for creating and configuring instances of http.Client.
Clients are created with the New() function, which takes a set of Options to configure the client. Options implement common configuration recipes, like disabling server TLS verification, or setting a simple proxy.
Example:
c, err := clients.New(clients.SkipVerify(), clients.Timeout(10 * time.Seconds))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New builds a new *http.Client. With no arguments, the client will be configured identically to the http.DefaultClient and http.DefaultTransport, but will be different instances (so they can be further modified without having a global effect).
The client can be further configured by passing Options.
Types ¶
type Option ¶
type Option interface { // Apply is called when constructing an http.Client. Apply // should make some configuration change to the argument. // // The client argument will not be nil. Apply(*http.Client) error }
Option is a configuration option for building an http.Client.
func CookieJar ¶
CookieJar installs a cookie jar into the client, configured with the options argument.
The argument will be nil.
func MaxRedirects ¶
MaxRedirects configures the max number of redirects the client will perform before giving up.
func NoRedirects ¶
func NoRedirects() Option
NoRedirects configures the client to no perform any redirects.
func SkipVerify ¶
SkipVerify sets the TLS config's InsecureSkipVerify flag.
type OptionFunc ¶
OptionFunc adapts a function to the Option interface.
type TLSOption ¶
A TLSOption configures the TLS configuration of the client.
The argument will never be nil. A new, default config will be created in necessary.
type TransportOption ¶
A TransportOption configures the client's transport.
The argument will never be nil. TransportOption will create a default http.Transport (configured identically to the http.DefaultClient.Transport) if necessary.
If the client's transport is not a *http.Transport, an error is returned.