httputil

package
v0.0.0-...-5561049 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBearerTokenFileRoundTripper

func NewBearerTokenFileRoundTripper(bearerFile string, rt http.RoundTripper) http.RoundTripper

Returns a new HTTP RoundTripper that adds the bearer token from the given file to a request header

func NewBearerTokenRoundTripper

func NewBearerTokenRoundTripper(token string, rt http.RoundTripper) http.RoundTripper

Returns a new HTTP RoundTripper that adds the given bearer token to a request header

func NewClient

func NewClient(cfg ClientConfig) (*http.Client, error)

Returns a new HTTP client based on the given configuration.

func NewRoundTripper

func NewRoundTripper(cfg ClientConfig) (http.RoundTripper, error)

Returns a new HTTP RoundTripper based on the given configuration.

func NewTLSConfig

func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error)

Returns a new tls.Config from the given configuration.

Types

type ClientConfig

type ClientConfig struct {
	// The bearer token for the client. Either this or the file below should be provided.
	BearerToken string `yaml:"bearer_token,omitempty"`
	// The bearer token file for the client. Either this or the token above should be provided.
	BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
	// HTTP proxy server to use to connect.
	ProxyURL URL `yaml:"proxy_url,omitempty"`
	// TLSConfig to use to connect.
	TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
}

The configuration for a HTTP client.

func FromYAML

func FromYAML(contents []byte) (ClientConfig, error)

FromYAML loads the configuration from a blob of YAML.

type TLSConfig

type TLSConfig struct {
	// The CA cert.
	CAFile string `yaml:"ca_file,omitempty"`
	// The client cert file.
	CertFile string `yaml:"cert_file,omitempty"`
	// The client key file.
	KeyFile string `yaml:"key_file,omitempty"`
	// Used to verify the hostname for the targets.
	ServerName string `yaml:"server_name,omitempty"`
	// Disables certificate validation.
	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}

The TLS configuration for a HTTP client.

type URL

type URL struct {
	*url.URL
}

Jump to

Keyboard shortcuts

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