Documentation ¶
Index ¶
- type Client
- func (c *Client) Delete(url string) (*Response, error)
- func (c *Client) Get(url string) (*Response, error)
- func (c *Client) Patch(url string, body io.ReadCloser) (*Response, error)
- func (c *Client) Post(url string, contentType string, body io.ReadCloser) (*Response, error)
- func (c *Client) Put(url string, body io.ReadCloser) (*Response, error)
- type Config
- type ContentType
- type DeleteRequest
- type GetRequest
- type PatchRequest
- type PostRequest
- type PutRequest
- type Request
- type RequestLoggableStrings
- type Requester
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a type that represents an HTTP client
type Config ¶
type Config struct { // TLS settings InsecureSkipVerify bool DialContext func(ctx context.Context, network, addr string) (net.Conn, error) ProxyHost string ProxyPort uint16 // Headers are automatically added to all requests Headers map[string]string // BaseURL is added as a prefix to all URLs BaseURL string // Specify if request/response bodies should be logged TraceBody bool TraceResponse bool Trace bool // GET's are on TRACE, PUT/PATCH/POST are on Debug, and DELETE are on Info Logger logger.Logger // RETRY HANDLING // Cancel the request after this timeout Timeout time.Duration // Number of retries to attempt Retries uint // Time to wait between retries RetryWait time.Duration // Amount to increase RetryWait with each failure, 2.0 is a good option for exponential backoff Factor float64 }
Config holds all configuration for the HTTP client
type ContentType ¶
type ContentType struct {
// contains filtered or unexported fields
}
type DeleteRequest ¶
type DeleteRequest struct {
*Request
}
func NewDeleteRequest ¶
func NewDeleteRequest(config *Config, url string) *DeleteRequest
NewDeleteRequest creates a new HTTP DELETE request
type GetRequest ¶
type GetRequest struct {
*Request
}
func NewGetRequest ¶
func NewGetRequest(config *Config, url string) *GetRequest
NewGetRequest creates a new HTTP GET request
type PatchRequest ¶
type PatchRequest struct {
*Request
}
func NewPatchRequest ¶
func NewPatchRequest(config *Config, url string, body io.ReadCloser) *PatchRequest
NewPatchRequest creates a new HTTP PATCH request
type PostRequest ¶
type PostRequest struct { *Request *ContentType }
func NewPostRequest ¶
func NewPostRequest(config *Config, url string, contentType string, body io.ReadCloser) *PostRequest
NewPostRequest creates a new HTTP POST request
type PutRequest ¶
type PutRequest struct {
*Request
}
func NewPutRequest ¶
func NewPutRequest(config *Config, url string, body io.ReadCloser) *PutRequest
NewPutRequest creates a new HTTP PUT request
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) GetLoggableStrings ¶
GetLoggableStrings returns the Headers and Body of the response as strings that can be logged while maintaining the request body's readability
type RequestLoggableStrings ¶
type Response ¶
Response embeds the stdlib http.Response type and extends its functionality
func (*Response) AsBytes ¶
AsBytes returns the body of the response as a byte slice, or returns an error if this is not possible
func (*Response) AsReader ¶
AsReader returns the response body as an io.Reader, or returns an error if this is not possible
func (*Response) AsString ¶
AsString returns the body of the response as a string, or returns an error if this is not possible
func (*Response) TraceMessage ¶
TraceMessage returns the Headers, StatusCode and Body of the response as strings that can be logged while maintaining the response body's readability