httpx

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(base http.RoundTripper, cfg ClientConfig) (c *http.Client, err error)

func NewTransport

func NewTransport(cfg TransportConfig) (http.RoundTripper, error)

Types

type Authorization

type Authorization struct {
	Type        string `yaml:"type,omitempty" json:"type,omitempty"`
	Credentials string `yaml:"credentials,omitempty" json:"credentials,omitempty"`
}

Authorization contains HTTP authorization credentials.

type BasicAuth

type BasicAuth struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

BasicAuth contains basic HTTP authentication credentials.

type ClientConfig

type ClientConfig struct {
	TransportConfig
	// The HTTP basic authentication credentials for the targets.
	BasicAuth *BasicAuth `yaml:"basic_auth,omitempty" json:"basic_auth,omitempty"`
	// The HTTP authorization credentials for the targets.
	Authorization *Authorization `yaml:"authorization,omitempty" json:"authorization,omitempty"`
	// The OAuth2 client credentials used to fetch a token for the targets.
	OAuth2 *OAuth2 `yaml:"oauth2,omitempty" json:"oauth2,omitempty"`
}

ClientConfig configures an HTTP client.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

type OAuth2

type OAuth2 struct {
	ClientID       string            `yaml:"clientId" json:"clientId"`
	ClientSecret   string            `yaml:"clientSecret" json:"clientSecret"`
	Scopes         []string          `yaml:"scopes,omitempty" json:"scopes,omitempty"`
	TokenURL       string            `yaml:"tokenUrl" json:"tokenUrl"`
	EndpointParams map[string]string `yaml:"endpointParams,omitempty" json:"endpointParams,omitempty"`
}

OAuth2 is the oauth2 client configuration.

type ProxyConfig

type ProxyConfig struct {
	// HTTP proxy server to use to connect to the targets.
	ProxyURL string `yaml:"proxyUrl,omitempty" json:"proxyUrl,omitempty"`
	// NoProxy contains addresses that should not use a proxy.
	NoProxy string `yaml:"noProxy,omitempty" json:"noProxy,omitempty"`
	// ProxyConnectHeader optionally specifies headers to send to
	// proxies during CONNECT requests. Assume that at least _some_ of
	// these headers are going to contain secrets and use Secret as the
	// value type instead of string.
	ProxyConnectHeader http.Header `yaml:"proxyConnectHeader,omitempty" json:"proxyConnectHeader,omitempty"`
}

func (ProxyConfig) ProxyFunc

func (p ProxyConfig) ProxyFunc() func(req *http.Request) (*url.URL, error)

func (ProxyConfig) Validate

func (p ProxyConfig) Validate() error

type TransportConfig

type TransportConfig struct {
	*ProxyConfig `yaml:",inline" json:",inline"`
	// TLSConfig to use to connect to the targets.
	TLS *conf.TLS `yaml:"tls,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL