Documentation ¶
Overview ¶
Package http provides utilities to perform HTTP requests.
Index ¶
- func CreateHTTPTransport(cfg pkgconfigmodel.Reader) *http.Transport
- func Get(ctx context.Context, URL string, headers map[string]string, ...) (string, error)
- func GetNumberOfWarnings() int
- func GetProxyChangedWarnings() []string
- func GetProxyIgnoredWarnings() []string
- func GetProxyTransportFunc(p *pkgconfigmodel.Proxy, cfg pkgconfigmodel.Reader) func(*http.Request) (*url.URL, error)
- func GetProxyUsedInFutureWarnings() []string
- func Put(ctx context.Context, URL string, headers map[string]string, body []byte, ...) (string, error)
- type APIToken
- type APITokenRenewCallback
- type ResetClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHTTPTransport ¶
func CreateHTTPTransport(cfg pkgconfigmodel.Reader) *http.Transport
CreateHTTPTransport creates an *http.Transport for use in the agent
func Get ¶
func Get(ctx context.Context, URL string, headers map[string]string, timeout time.Duration, cfg pkgconfigmodel.Reader) (string, error)
Get is a high level helper to query an URL and return its body as a string
func GetNumberOfWarnings ¶
func GetNumberOfWarnings() int
GetNumberOfWarnings returns the total number of warnings
func GetProxyChangedWarnings ¶
func GetProxyChangedWarnings() []string
GetProxyChangedWarnings returns the list of URL whose proxy behavior will change in the future
func GetProxyIgnoredWarnings ¶
func GetProxyIgnoredWarnings() []string
GetProxyIgnoredWarnings returns the list of URL which will ignore the proxy in the future
func GetProxyTransportFunc ¶
func GetProxyTransportFunc(p *pkgconfigmodel.Proxy, cfg pkgconfigmodel.Reader) func(*http.Request) (*url.URL, error)
GetProxyTransportFunc return a proxy function for a http.Transport that would return the right proxy depending on the configuration.
func GetProxyUsedInFutureWarnings ¶
func GetProxyUsedInFutureWarnings() []string
GetProxyUsedInFutureWarnings returns the list of URL which will use a proxy in the future
Types ¶
type APIToken ¶
type APIToken struct { Value string ExpirationDate time.Time sync.RWMutex // contains filtered or unexported fields }
APIToken is an API token with auto renew when expired
func NewAPIToken ¶
func NewAPIToken(cb APITokenRenewCallback) *APIToken
NewAPIToken returns a new APIToken
type APITokenRenewCallback ¶
APITokenRenewCallback represents the callback type to fetch a token
type ResetClient ¶
type ResetClient struct {
// contains filtered or unexported fields
}
ResetClient wraps (http.Client).Do and resets the underlying connections at the configured interval
func NewResetClient ¶
func NewResetClient(resetInterval time.Duration, httpClientFactory func() *http.Client) *ResetClient
NewResetClient returns an initialized Client resetting connections at the passed resetInterval ("0" means that no reset is performed). The underlying http.Client used will be created using the passed http client factory.