Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Delete(ctx context.Context, resource string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, resource string, headers map[string]string) (*http.Response, error)
- func (c *Client) Patch(ctx context.Context, resource string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) Post(ctx context.Context, resource string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) Put(ctx context.Context, resource string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) Stream(ctx context.Context, method string, resource string, body io.Reader, ...) (io.Reader, error)
- type ClientOpt
- type Config
- type ErrCopy
- type ErrDecode
- type ErrInvalidResource
- type ErrNewRequest
- type ErrRateLimit
- type ErrRequest
- type ErrRetryCopy
- type ErrStatusCode
- type RetryTransport
Constants ¶
const ( Kib int64 Mib Gib )
const ( DefaultTimeout int = 10 DefaultReadByteLimit int64 = 15 * Mib MaxRateLimitKeys int = 65536 MaxIdleConns int = 100 MaxConnsPerHost int = 100 )
const (
DefaultRetryMax int = 3
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, resource string, body io.Reader, headers map[string]string, decoded interface{}) (*http.Response, error)
Delete makes a DELETE request to the supplied endpoint and returns the response. If a struct pointer is supplied, the response body will be decoded into it
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, resource string, headers map[string]string) (*http.Response, error)
Get makes a GET request to the supplied endpoint and returns the response.
func (*Client) Patch ¶
func (c *Client) Patch(ctx context.Context, resource string, body io.Reader, headers map[string]string, decoded interface{}) (*http.Response, error)
Patch makes a PATCH request to the supplied endpoint and returns the response. If a struct pointer is supplied, the response body will be decoded into it
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, resource string, body io.Reader, headers map[string]string, decoded interface{}) (*http.Response, error)
Post makes a POST request to the supplied endpoint and returns the response. If a struct pointer is supplied, the response body will be decoded into it
func (*Client) Put ¶
func (c *Client) Put(ctx context.Context, resource string, body io.Reader, headers map[string]string, decoded interface{}) (*http.Response, error)
Put makes a PUT request to the supplied endpoint and returns the response. If a struct pointer is supplied, the response body will be decoded into it
type ClientOpt ¶ added in v0.0.2
func WithCredentials ¶
func WithCredentials(ctx context.Context, id string, secret string, baseUrl string, resource string, scopes ...string) ClientOpt
WithCredentials sets up oauth2 and replaces the default http client
func WithCustomClient ¶
WithCustomClient replaces the default http client with the supplied one
func WithDefaultHeaders ¶
WithDefaultHeaders adds default headers to the client
func WithRateLimiter ¶
WithRateLimiter configures a rate limiter with the supplied limit (per minute)
type ErrDecode ¶ added in v0.0.2
type ErrDecode struct {
// contains filtered or unexported fields
}
type ErrInvalidResource ¶ added in v0.0.2
type ErrInvalidResource struct {
// contains filtered or unexported fields
}
func (*ErrInvalidResource) Error ¶ added in v0.0.2
func (e *ErrInvalidResource) Error() string
type ErrNewRequest ¶ added in v0.0.2
type ErrNewRequest struct {
// contains filtered or unexported fields
}
func (*ErrNewRequest) Error ¶ added in v0.0.2
func (e *ErrNewRequest) Error() string
type ErrRateLimit ¶ added in v0.0.2
type ErrRateLimit struct {
// contains filtered or unexported fields
}
func (*ErrRateLimit) Error ¶ added in v0.0.2
func (e *ErrRateLimit) Error() string
type ErrRequest ¶ added in v0.0.2
type ErrRequest struct {
// contains filtered or unexported fields
}
func (*ErrRequest) Error ¶ added in v0.0.2
func (e *ErrRequest) Error() string
type ErrRetryCopy ¶ added in v0.0.2
type ErrRetryCopy struct {
// contains filtered or unexported fields
}
func (*ErrRetryCopy) Error ¶ added in v0.0.2
func (e *ErrRetryCopy) Error() string
type ErrStatusCode ¶ added in v0.0.2
type ErrStatusCode struct {
// contains filtered or unexported fields
}
func (*ErrStatusCode) Error ¶ added in v0.0.2
func (e *ErrStatusCode) Error() string
type RetryTransport ¶
type RetryTransport struct {
// contains filtered or unexported fields
}
func NewRetryTransport ¶
func NewRetryTransport(transport *http.Transport, maxRetry int) (*RetryTransport, error)
NewRetryTransport wraps the supplied http transport with a retryable implementation