Documentation ¶
Index ¶
- Constants
- type BadStatusCode
- 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 ClientOption
- type Config
- type CopyError
- type DecodeError
- type InvalidResource
- type RequestError
- type RetryTransport
Constants ¶
const ( DefaultTimeout int = 10 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 BadStatusCode ¶
type BadStatusCode struct {
// contains filtered or unexported fields
}
func (*BadStatusCode) Error ¶
func (e *BadStatusCode) Error() string
type Client ¶
type Client struct { Http *http.Client Credentials *clientcredentials.Config BaseUrl *url.URL RateLimiter *throttled.GCRARateLimiterCtx Headers map[string]string }
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, decoded interface{}) (*http.Response, error)
Get makes a GET 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) 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 ClientOption ¶
func WithCredentials ¶
func WithCredentials(ctx context.Context, clientId, key, tokenUrl string) ClientOption
WithCredentials sets up oauth2 and replaces the default http client
func WithCustomClient ¶
func WithCustomClient(client *http.Client) ClientOption
WithCustomClient replaces the default http client with the supplied one
func WithDefaultHeaders ¶
func WithDefaultHeaders(headers map[string]string) ClientOption
WithDefaultHeaders adds default headers to the client
func WithRateLimiter ¶
func WithRateLimiter(rateLimit int) ClientOption
WithRateLimiter configures a rate limiter with the supplied limit (per minute)
type DecodeError ¶
type DecodeError struct {
// contains filtered or unexported fields
}
func (*DecodeError) Error ¶
func (e *DecodeError) Error() string
type InvalidResource ¶
type InvalidResource struct {
// contains filtered or unexported fields
}
func (*InvalidResource) Error ¶
func (e *InvalidResource) Error() string
type RequestError ¶
type RequestError struct {
// contains filtered or unexported fields
}
func (*RequestError) Error ¶
func (e *RequestError) 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