Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Delete(ctx context.Context, req *Request) *Response
- func (c *Client) Get(ctx context.Context, req *Request) *Response
- func (c *Client) Head(ctx context.Context, req *Request) *Response
- func (c *Client) Options(ctx context.Context, req *Request) *Response
- func (c *Client) PatchForm(ctx context.Context, req *Request) *Response
- func (c *Client) PatchJSON(ctx context.Context, req *Request) *Response
- func (c *Client) PatchMultipart(ctx context.Context, req *Request) *Response
- func (c *Client) PostForm(ctx context.Context, req *Request) *Response
- func (c *Client) PostJSON(ctx context.Context, req *Request) *Response
- func (c *Client) PostMultipart(ctx context.Context, req *Request) *Response
- func (c *Client) PutForm(ctx context.Context, req *Request) *Response
- func (c *Client) PutJSON(ctx context.Context, req *Request) *Response
- func (c *Client) PutMultipart(ctx context.Context, req *Request) *Response
- type File
- type Opts
- type Request
- type Response
- func Delete(ctx context.Context, req *Request) *Response
- func Get(ctx context.Context, req *Request) *Response
- func Head(ctx context.Context, req *Request) *Response
- func Options(ctx context.Context, req *Request) *Response
- func PatchForm(ctx context.Context, req *Request) *Response
- func PatchJSON(ctx context.Context, req *Request) *Response
- func PatchMultipart(ctx context.Context, req *Request) *Response
- func PostForm(ctx context.Context, req *Request) *Response
- func PostJSON(ctx context.Context, req *Request) *Response
- func PostMultipart(ctx context.Context, req *Request) *Response
- func PutForm(ctx context.Context, req *Request) *Response
- func PutJSON(ctx context.Context, req *Request) *Response
- func PutMultipart(ctx context.Context, req *Request) *Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRequestNil = errors.New("httpclient: request cannot be nil") ErrRequestURLNil = errors.New("httpclient: request url cannot be empty") )
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct { MaxIdleConns int IdleConnTimeout time.Duration // Logger enable log for successfull or failed request. EnableLogger bool // MaxRetry maximum retry for transient errors. Ignored for POST or PATCH as it's not safe. MaxRetry int // RetryPolicy if MaxRetry is zero then this will be ignored. // It can use customized retry policy, if MaxRetry is set and RetryPolicy is nil, then default will be used. RetryPolicy func(*http.Response, error) bool // BackOffPolicy if MaxRetry is zero then this will be ignored. If RetryPolicy is nil then this will be ignored. // It can use customized backoff policy, if MaxRetry is set and RetryPolicy is set and BackOffPolicy is nil, then default will be used. BackOffPolicy func(attempt int, minWait time.Duration, maxWait time.Duration) time.Duration // MinBackOff minimum wait for backoff. If nil then default will be set. MinBackOff *time.Duration // MaxBackOff maximum wait for backoff. If nil then default will be set MaxBackOff *time.Duration // Transport Optional. If you want to specify your own RoundTrip logic. Otherwise will be set to http.DefaultTransport. // If MaxRetry is more than zero, then this Transport will be executed after retry RoundTripper. Transport http.RoundTripper }
type Request ¶
type Request struct { BaseURL string Header http.Header URLValues url.Values // for get method Body map[string]interface{} // for x-www-form-urlencoded, json payload, and multipart/form non-binary data Files []File // for multipart/form binary data RequestID string // unique identifier for each request. E.g. uuid v4. If empty, then will be set automatically using uuid v4. }
func (*Request) FormURLEncoded ¶
FormURLEncoded create url encoded from Body.
func (*Request) MultipartForm ¶
MultipartForm create multipart/form non-binary and binary data
Click to show internal directories.
Click to hide internal directories.