Documentation ¶
Index ¶
- type ClientOption
- type HttpClient
- func (c *HttpClient) Close()
- func (c *HttpClient) Delete(ctx context.Context, path string, opts ...RequestOption) (*HttpResponse, error)
- func (c *HttpClient) Get(ctx context.Context, path string, opts ...RequestOption) (*HttpResponse, error)
- func (c *HttpClient) Patch(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
- func (c *HttpClient) Post(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
- func (c *HttpClient) Put(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
- type HttpResponse
- type JsonBody
- type MultipartBody
- type RequestOption
- type UrlEncodedBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOption ¶
type ClientOption func(*HttpClient)
Client options
func WithHttpHeaders ¶
func WithHttpHeaders(headers http.Header) ClientOption
func WithHttpTimeout ¶
func WithHttpTimeout(timeout time.Duration) ClientOption
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(baseURL string, opts ...ClientOption) *HttpClient
Create a new HTTP client
func (*HttpClient) Close ¶
func (c *HttpClient) Close()
Close closes the idle connections of the underlying HTTP client.
The client can be reused after closing as per the http.Client documentation.
func (*HttpClient) Delete ¶
func (c *HttpClient) Delete(ctx context.Context, path string, opts ...RequestOption) (*HttpResponse, error)
func (*HttpClient) Get ¶
func (c *HttpClient) Get(ctx context.Context, path string, opts ...RequestOption) (*HttpResponse, error)
Request methods
func (*HttpClient) Patch ¶
func (c *HttpClient) Patch(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
func (*HttpClient) Post ¶
func (c *HttpClient) Post(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
func (*HttpClient) Put ¶
func (c *HttpClient) Put(ctx context.Context, path string, body isHttpBody, opts ...RequestOption) (*HttpResponse, error)
type HttpResponse ¶
type HttpResponse struct { Status string `json:"status"` StatusCode int `json:"status_code"` Headers http.Header `json:"headers"` Body []byte `json:"body"` Request *http.Request `json:"request"` }
func (*HttpResponse) DecodeJSON ¶
func (r *HttpResponse) DecodeJSON(v interface{}) error
func (*HttpResponse) String ¶
func (r *HttpResponse) String() string
type MultipartBody ¶
func NewMultipartBody ¶
func NewMultipartBody() *MultipartBody
type RequestOption ¶
type RequestOption func(*requestOptions)
func WithHttpQueryParams ¶
func WithHttpQueryParams(params map[string]string) RequestOption
func WithHttpRetries ¶
func WithHttpRetries(retries int, wait time.Duration) RequestOption
func WithRequestHttpHeaders ¶
func WithRequestHttpHeaders(headers http.Header) RequestOption
type UrlEncodedBody ¶
func NewUrlEncodedBody ¶
func NewUrlEncodedBody() *UrlEncodedBody
Click to show internal directories.
Click to hide internal directories.