Documentation ¶
Overview ¶
Package httpclient provides HTTP client configuration for SFTPGo hooks
Index ¶
- func Get(url string) (*http.Response, error)
- func GetHTTPClient() *http.Client
- func GetRetraybleHTTPClient() *retryablehttp.Client
- func Post(url string, contentType string, body io.Reader) (*http.Response, error)
- func RetryableGet(url string) (*http.Response, error)
- func RetryablePost(url string, contentType string, body io.Reader) (*http.Response, error)
- type Config
- type Header
- type TLSKeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHTTPClient ¶
GetHTTPClient returns a new HTTP client with the configured parameters
func GetRetraybleHTTPClient ¶
func GetRetraybleHTTPClient() *retryablehttp.Client
GetRetraybleHTTPClient returns an HTTP client that retry a request on error. It uses the configured retry parameters
func RetryableGet ¶
RetryableGet issues a GET to the specified URL using the retryable client
Types ¶
type Config ¶
type Config struct { // Timeout specifies a time limit, in seconds, for a request Timeout float64 `json:"timeout" mapstructure:"timeout"` // RetryWaitMin defines the minimum waiting time between attempts in seconds RetryWaitMin int `json:"retry_wait_min" mapstructure:"retry_wait_min"` // RetryWaitMax defines the minimum waiting time between attempts in seconds RetryWaitMax int `json:"retry_wait_max" mapstructure:"retry_wait_max"` // RetryMax defines the maximum number of attempts RetryMax int `json:"retry_max" mapstructure:"retry_max"` // CACertificates defines extra CA certificates to trust. // The paths can be absolute or relative to the config dir. // Adding trusted CA certificates is a convenient way to use self-signed // certificates without defeating the purpose of using TLS CACertificates []string `json:"ca_certificates" mapstructure:"ca_certificates"` // Certificates defines the certificates to use for mutual TLS Certificates []TLSKeyPair `json:"certificates" mapstructure:"certificates"` // if enabled the HTTP client accepts any TLS certificate presented by // the server and any host name in that certificate. // In this mode, TLS is susceptible to man-in-the-middle attacks. // This should be used only for testing. SkipTLSVerify bool `json:"skip_tls_verify" mapstructure:"skip_tls_verify"` // Headers defines a list of http headers to add to each request Headers []Header `json:"headers" mapstructure:"headers"` // contains filtered or unexported fields }
Config defines the configuration for HTTP clients. HTTP clients are used for executing hooks such as the ones used for custom actions, external authentication and pre-login user modifications
func (*Config) Initialize ¶
Initialize configures HTTP clients
type Header ¶
type Header struct { Key string `json:"key" mapstructure:"key"` Value string `json:"value" mapstructure:"value"` URL string `json:"url" mapstructure:"url"` }
Header defines an HTTP header. If the URL is not empty, the header is added only if the requested URL starts with the one specified
type TLSKeyPair ¶
type TLSKeyPair struct { Cert string `json:"cert" mapstructure:"cert"` Key string `json:"key" mapstructure:"key"` }
TLSKeyPair defines the paths for a TLS key pair