Documentation ¶
Index ¶
- func ResponseValidator(resp *http.Response) error
- type Client
- func (c *Client) DoRequest(ctx context.Context, method, path string, parser ResponseParser, ...) error
- func (c *Client) DoRequestJson(ctx context.Context, method, path string, intf interface{}, ...) error
- func (c *Client) DoRequestNoBody(ctx context.Context, method, path string, options ...RequestOption) error
- func (c *Client) DoRequestString(ctx context.Context, method, path string, out *string, ...) error
- func (c *Client) DownloadFile(ctx context.Context, method, path string, wr io.Writer, ...) error
- func (c *Client) Get(ctx context.Context, path string, options ...RequestOption) error
- func (c *Client) GetJson(ctx context.Context, path string, intf interface{}, options ...RequestOption) error
- type Option
- type RequestOption
- type ResponseParser
- type StatusCodeError
- type ValidateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResponseValidator ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoRequest ¶
func (c *Client) DoRequest(ctx context.Context, method, path string, parser ResponseParser, options ...RequestOption) error
func (*Client) DoRequestJson ¶
func (*Client) DoRequestNoBody ¶
func (*Client) DoRequestString ¶
func (*Client) DownloadFile ¶
type Option ¶
type Option func(*Client)
func RequestBasicAuthOption ¶
RequestBasicAuthOption add basic credentials to all the requests
func WithHttpClient ¶
func WithHttpClient(client httpClient) Option
WithHttpClient setup a custom http client
func WithRequestOptions ¶
func WithRequestOptions(fn ...RequestOption) Option
WithRequestFilters add filters which will be applied to all the requests
func WithResponseValidator ¶
func WithResponseValidator(v ValidateResponse) Option
WithResponseValidator set a custom response validator function
type RequestOption ¶
func WithBodyOpt ¶
func WithBodyOpt(body io.Reader) RequestOption
RequestBodyOption add body to a request
func WithHeadersOpt ¶
func WithHeadersOpt(header http.Header) RequestOption
WithHeadersOpt add headers to a request
func WithQueryOpt ¶
func WithQueryOpt(query url.Values) RequestOption
WithQueryOpt add query to request
type ResponseParser ¶
func JsonParser ¶
func JsonParser(dst interface{}) ResponseParser
func NoBodyParser ¶
func NoBodyParser(log *log.Logger) ResponseParser
func RawBodyParser ¶
func RawBodyParser(dst *[]byte) ResponseParser
func RawStringParser ¶
func RawStringParser(dst *string) ResponseParser
type StatusCodeError ¶
StatusCodeError represents an http response error
func (StatusCodeError) Error ¶
func (t StatusCodeError) Error() string
func (StatusCodeError) HTTPStatusCode ¶
func (t StatusCodeError) HTTPStatusCode() int
type ValidateResponse ¶
Click to show internal directories.
Click to hide internal directories.