Documentation ¶
Overview ¶
Package resty HTTP and REST client library with parallel feature
Index ¶
- Variables
- type Client
- type Handle
- type Option
- type Resty
- func (r *Resty) Do(ctx context.Context, method string, body io.Reader, urls ...string) *Resty
- func (r *Resty) DoDelete(ctx context.Context, urls ...string) *Resty
- func (r *Resty) DoGet(ctx context.Context, urls ...string) *Resty
- func (r *Resty) DoPost(ctx context.Context, body io.Reader, urls ...string) *Resty
- func (r *Resty) DoPut(ctx context.Context, body io.Reader, urls ...string) *Resty
- func (r *Resty) Then(fn Handle) *Resty
- func (r *Resty) Wait() []error
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultDialTimeout default timeout of a dialer DefaultDialTimeout = 5 * time.Second // DefaultRequestTimeout default time out of a http request DefaultRequestTimeout = 10 * time.Second // DefaultRetry retry times if a request is failed with 5xx status code DefaultRetry = 3 // DefaultTransport default http transport DefaultTransport *http.Transport )
View Source
var CreateClient = func(t *http.Transport, timeout time.Duration) Client { client := &http.Client{ Transport: t, } if timeout > 0 { client.Timeout = timeout } return client }
CreateClient a function that create a client instance
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle func(req *http.Request, resp *http.Response, respBody []byte, cf context.CancelFunc, err error) error
Handle handler of http response
type Option ¶
type Option func(*Resty)
Option set restry option
func WithHeader ¶
WithHeader set header for http request
func WithRequestInterceptor ¶ added in v1.7.3
WithRequestInterceptor intercept request
func WithRetry ¶
WithRetry set retry times if request is failure with 5xx status code. retry is ingore if it is less than 1.
func WithTimeout ¶
WithTimeout set timeout of http request.
func WithTransport ¶ added in v1.7.4
WithTransport set transport
type Resty ¶
type Resty struct {
// contains filtered or unexported fields
}
Resty HTTP and REST client library with parallel feature
func (*Resty) DoDelete ¶ added in v1.7.3
DoDelete execute http requests with DELETE method in parallel
Click to show internal directories.
Click to hide internal directories.