Documentation ¶
Index ¶
- Variables
- func Error(span trace.Span, err error) bool
- type AuthConfig
- type Client
- func (c *Client) Auth(username, password string) *Client
- func (c *Client) BaseURL(url string) *Client
- func (c *Client) CacheDNS(val bool) *Client
- func (c *Client) ConnectTo(host string) *Client
- func (c *Client) Digest(val bool) *Client
- func (c *Client) DisableKeepAlive(val bool) *Client
- func (c *Client) Header(key, val string) *Client
- func (c *Client) InsecureSkipVerify(val bool) *Client
- func (c *Client) NTLM(val bool) *Client
- func (c *Client) NTLMV2(val bool) *Client
- func (c *Client) OAuth(config middlewares.OauthConfig) *Client
- func (c *Client) Proxy(url string) *Client
- func (c *Client) R(ctx context.Context) *Request
- func (c *Client) Retry(maxRetries uint, baseDuration time.Duration, exponent float64) *Client
- func (c *Client) TLSConfig(conf TLSConfig) (*Client, error)
- func (c *Client) Timeout(d time.Duration) *Client
- func (c *Client) Trace(config TraceConfig) *Client
- func (c *Client) TraceToStdout(config TraceConfig) *Client
- func (c *Client) Use(middlewares ...middlewares.Middleware) *Client
- func (c *Client) UserAgent(agent string) *Client
- type OauthConfig
- type Request
- func (r *Request) Body(v any) error
- func (r *Request) Delete(url string) (*Response, error)
- func (r *Request) Do(method, reqURL string) (resp *Response, err error)
- func (r *Request) Get(url string) (*Response, error)
- func (r *Request) GetHeader(key string) string
- func (r *Request) GetHeaders() map[string]string
- func (r *Request) Header(key, value string) *Request
- func (r *Request) Patch(url string, body any) (*Response, error)
- func (r *Request) Post(url string, body any) (*Response, error)
- func (r *Request) Put(url string, body any) (*Response, error)
- func (r *Request) QueryParam(key, value string) *Request
- func (r *Request) QueryParamAdd(key, value string) *Request
- func (r *Request) Retry(maxRetries uint, baseDuration time.Duration, exponent float64) *Request
- type Response
- func (h *Response) AsJSON() (map[string]any, error)
- func (r *Response) AsString() (string, error)
- func (r *Response) GetHeaders() map[string]string
- func (h *Response) GetSSLAge() *time.Duration
- func (r *Response) Into(dest any) error
- func (h *Response) IsJSON() bool
- func (r *Response) IsOK(responseCodes ...int) bool
- type RetryConfig
- type TLSConfig
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
var AuthStyleAutoDetect = middlewares.AuthStyleAutoDetect
var AuthStyleInHeader = middlewares.AuthStyleInHeader
var AuthStyleInParams = middlewares.AuthStyleInParams
var TraceAll = TraceConfig{ MaxBodyLength: 4096, Body: true, Response: true, QueryParam: true, Headers: true, ResponseHeaders: true, TLS: true, }
var TraceHeaders = TraceConfig{ Body: false, Response: false, QueryParam: true, Headers: true, ResponseHeaders: true, TLS: false, }
Functions ¶
Types ¶
type AuthConfig ¶ added in v1.13.0
type AuthConfig struct { // Username for basic Auth Username string // Password for basic Auth Password string // Use digest access authentication Digest bool // Ntlm controls whether to use NTLM Ntlm bool // Ntlmv2 controls whether to use NTLMv2 Ntlmv2 bool }
func (*AuthConfig) IsEmpty ¶ added in v1.16.0
func (a *AuthConfig) IsEmpty() bool
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a type that represents an HTTP client
func NewClient ¶
func NewClient() *Client
NewClient configures a new HTTP client using given configuration
func (*Client) ConnectTo ¶ added in v1.13.0
ConnectTo specifies the host:port on which the URL is sought. If empty, the URL's host is used.
func (*Client) DisableKeepAlive ¶ added in v1.13.0
DisableKeepAlives prevents reuse of TCP connections
func (*Client) InsecureSkipVerify ¶ added in v1.13.0
InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name
func (*Client) OAuth ¶ added in v1.15.0
func (c *Client) OAuth(config middlewares.OauthConfig) *Client
func (*Client) Retry ¶ added in v1.13.0
Retry configuration retrying on failure with exponential backoff.
Base duration of a second & an exponent of 2 is a good option.
func (*Client) Timeout ¶ added in v1.13.0
Timeout specifies a time limit for requests made by this Client.
Default: 2 minutes
func (*Client) Trace ¶ added in v1.15.0
func (c *Client) Trace(config TraceConfig) *Client
func (*Client) TraceToStdout ¶ added in v1.16.0
func (c *Client) TraceToStdout(config TraceConfig) *Client
func (*Client) Use ¶ added in v1.13.0
func (c *Client) Use(middlewares ...middlewares.Middleware) *Client
Use adds middleware to the client that wraps the client's transport
type OauthConfig ¶ added in v1.17.0
type OauthConfig = middlewares.OauthConfig
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) Do ¶ added in v1.13.0
Do performs an HTTP request with the specified method and URL.
func (*Request) GetHeaders ¶ added in v1.16.0
func (*Request) QueryParam ¶ added in v1.13.0
QueryParam sets query params
func (*Request) QueryParamAdd ¶ added in v1.31.24
QueryParamAdd adds value to query param key
type Response ¶
type Response struct { // The underlying http.Response is embed into Response. *http.Response // Request is the Response's related Request. Request *Request RawRequest *http.Request }
Response extends the stdlib http.Response type and extends its functionality
func (*Response) GetHeaders ¶ added in v1.16.0
type RetryConfig ¶ added in v1.13.0
type TLSConfig ¶ added in v1.22.2
type TLSConfig struct { // InsecureSkipVerify controls whether a client verifies the server's // certificate chain and host name InsecureSkipVerify bool // HandshakeTimeout defaults to 10 seconds HandshakeTimeout time.Duration // PEM encoded certificate of the CA to verify the server certificate CA string // PEM encoded client certificate Cert string // PEM encoded client private key Key string }
type TraceConfig ¶ added in v1.15.0
type TraceConfig = middlewares.TraceConfig