Documentation ¶
Index ¶
- func DebugWrappers(rt http.RoundTripper) http.RoundTripper
- func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTripper, error)
- func New(config *Config) (http.RoundTripper, error)
- func NewBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper
- func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper
- func NewImpersonatingRoundTripper(impersonate string, delegate http.RoundTripper) http.RoundTripper
- func NewUserAgentRoundTripper(agent string, rt http.RoundTripper) http.RoundTripper
- func TLSConfigFor(c *Config) (*tls.Config, error)
- type Config
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugWrappers ¶
func DebugWrappers(rt http.RoundTripper) http.RoundTripper
DebugWrappers wraps a round tripper and logs based on the current log level.
func HTTPWrappersForConfig ¶
func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTripper, error)
HTTPWrappersForConfig wraps a round tripper with any relevant layered behavior from the config. Exposed to allow more clients that need HTTP-like behavior but then must hijack the underlying connection (like WebSocket or HTTP2 clients). Pure HTTP clients should use the RoundTripper returned from New.
func New ¶
func New(config *Config) (http.RoundTripper, error)
New returns an http.RoundTripper that will provide the authentication or transport level security defined by the provided Config.
func NewBasicAuthRoundTripper ¶ added in v0.4.0
func NewBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper
NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a request unless it has already been set.
func NewBearerAuthRoundTripper ¶ added in v0.4.0
func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper
NewBearerAuthRoundTripper adds the provided bearer token to a request unless the authorization header has already been set.
func NewImpersonatingRoundTripper ¶ added in v1.3.0
func NewImpersonatingRoundTripper(impersonate string, delegate http.RoundTripper) http.RoundTripper
NewImpersonatingRoundTripper will add an Act-As header to a request unless it has already been set.
func NewUserAgentRoundTripper ¶ added in v0.4.0
func NewUserAgentRoundTripper(agent string, rt http.RoundTripper) http.RoundTripper
Types ¶
type Config ¶
type Config struct { // UserAgent is an optional field that specifies the caller of this // request. UserAgent string // The base TLS configuration for this transport. TLS TLSConfig // Username and password for basic authentication Username string Password string // Bearer token for authentication BearerToken string // Impersonate is the username that this Config will impersonate Impersonate string // Transport may be used for custom HTTP behavior. This attribute may // not be specified with the TLS client certificate options. Use // WrapTransport for most client level operations. Transport http.RoundTripper // WrapTransport will be invoked for custom HTTP behavior after the // underlying transport is initialized (either the transport created // from TLSClientConfig, Transport, or http.DefaultTransport). The // config may layer other RoundTrippers on top of the returned // RoundTripper. WrapTransport func(rt http.RoundTripper) http.RoundTripper }
Config holds various options for establishing a transport.
func (*Config) HasBasicAuth ¶
HasBasicAuth returns whether the configuration has basic authentication or not.
func (*Config) HasCertAuth ¶
HasCertAuth returns whether the configuration has certificate authentication or not.
func (*Config) HasTokenAuth ¶
HasTokenAuth returns whether the configuration has token authentication or not.
type TLSConfig ¶
type TLSConfig struct { CAFile string // Path of the PEM-encoded server trusted root certificates. CertFile string // Path of the PEM-encoded client certificate. KeyFile string // Path of the PEM-encoded client key. Insecure bool // Server should be accessed without verifying the certificate. For testing only. CAData []byte // Bytes of the PEM-encoded server trusted root certificates. Supercedes CAFile. CertData []byte // Bytes of the PEM-encoded client certificate. Supercedes CertFile. KeyData []byte // Bytes of the PEM-encoded client key. Supercedes KeyFile. }
TLSConfig holds the information needed to set up a TLS transport.