Versions in this module Expand all Collapse all v2 v2.6.1 Aug 27, 2021 Changes in this version + const MethodDelete + const MethodGet + const MethodHead + const MethodOptions + const MethodPatch + const MethodPost + const MethodPut + const Version + func Backoff(operation func() (*Response, error), options ...Option) error + func DetectContentType(body interface{}) string + func IsJSONType(ct string) bool + func IsStringEmpty(str string) bool + func IsXMLType(ct string) bool + func Unmarshalc(c *Client, ct string, b []byte, d interface{}) (err error) + type Client struct + AllowGetMethodPayload bool + AuthScheme string + Cookies []*http.Cookie + Debug bool + DisableWarn bool + Error reflect.Type + FormData url.Values + Header http.Header + HeaderAuthorizationKey string + HostURL string + JSONMarshal func(v interface{}) ([]byte, error) + JSONUnmarshal func(data []byte, v interface{}) error + QueryParam url.Values + RetryAfter RetryAfterFunc + RetryConditions []RetryConditionFunc + RetryCount int + RetryHooks []OnRetryFunc + RetryMaxWaitTime time.Duration + RetryWaitTime time.Duration + Token string + UserInfo *User + func New() *Client + func NewWithClient(hc *http.Client) *Client + func NewWithLocalAddr(localAddr net.Addr) *Client + func (c *Client) AddRetryAfterErrorCondition() *Client + func (c *Client) AddRetryCondition(condition RetryConditionFunc) *Client + func (c *Client) AddRetryHook(hook OnRetryFunc) *Client + func (c *Client) DisableTrace() *Client + func (c *Client) EnableTrace() *Client + func (c *Client) GetClient() *http.Client + func (c *Client) IsProxySet() bool + func (c *Client) NewRequest() *Request + func (c *Client) OnAfterResponse(m ResponseMiddleware) *Client + func (c *Client) OnBeforeRequest(m RequestMiddleware) *Client + func (c *Client) OnError(h ErrorHook) *Client + func (c *Client) OnRequestLog(rl RequestLogCallback) *Client + func (c *Client) OnResponseLog(rl ResponseLogCallback) *Client + func (c *Client) R() *Request + func (c *Client) RemoveProxy() *Client + func (c *Client) SetAllowGetMethodPayload(a bool) *Client + func (c *Client) SetAuthScheme(scheme string) *Client + func (c *Client) SetAuthToken(token string) *Client + func (c *Client) SetBasicAuth(username, password string) *Client + func (c *Client) SetCertificates(certs ...tls.Certificate) *Client + func (c *Client) SetCloseConnection(close bool) *Client + func (c *Client) SetContentLength(l bool) *Client + func (c *Client) SetCookie(hc *http.Cookie) *Client + func (c *Client) SetCookieJar(jar http.CookieJar) *Client + func (c *Client) SetCookies(cs []*http.Cookie) *Client + func (c *Client) SetDebug(d bool) *Client + func (c *Client) SetDebugBodyLimit(sl int64) *Client + func (c *Client) SetDisableWarn(d bool) *Client + func (c *Client) SetDoNotParseResponse(parse bool) *Client + func (c *Client) SetError(err interface{}) *Client + func (c *Client) SetFormData(data map[string]string) *Client + func (c *Client) SetHeader(header, value string) *Client + func (c *Client) SetHeaderVerbatim(header, value string) *Client + func (c *Client) SetHeaders(headers map[string]string) *Client + func (c *Client) SetHostURL(url string) *Client + func (c *Client) SetJSONEscapeHTML(b bool) *Client + func (c *Client) SetLogger(l Logger) *Client + func (c *Client) SetOutputDirectory(dirPath string) *Client + func (c *Client) SetPathParam(param, value string) *Client + func (c *Client) SetPathParams(params map[string]string) *Client + func (c *Client) SetPreRequestHook(h PreRequestHook) *Client + func (c *Client) SetProxy(proxyURL string) *Client + func (c *Client) SetQueryParam(param, value string) *Client + func (c *Client) SetQueryParams(params map[string]string) *Client + func (c *Client) SetRedirectPolicy(policies ...interface{}) *Client + func (c *Client) SetRetryAfter(callback RetryAfterFunc) *Client + func (c *Client) SetRetryCount(count int) *Client + func (c *Client) SetRetryMaxWaitTime(maxWaitTime time.Duration) *Client + func (c *Client) SetRetryWaitTime(waitTime time.Duration) *Client + func (c *Client) SetRootCertificate(pemFilePath string) *Client + func (c *Client) SetRootCertificateFromString(pemContent string) *Client + func (c *Client) SetScheme(scheme string) *Client + func (c *Client) SetTLSClientConfig(config *tls.Config) *Client + func (c *Client) SetTimeout(timeout time.Duration) *Client + func (c *Client) SetTransport(transport http.RoundTripper) *Client + type ErrorHook func(*Request, error) + type File struct + Name string + ParamName string + func (f *File) String() string + type Logger interface + Debugf func(format string, v ...interface{}) + Errorf func(format string, v ...interface{}) + Warnf func(format string, v ...interface{}) + type MultipartField struct + ContentType string + FileName string + Param string + type OnRetryFunc func(*Response, error) + type Option func(*Options) + func MaxWaitTime(value time.Duration) Option + func Retries(value int) Option + func RetryConditions(conditions []RetryConditionFunc) Option + func RetryHooks(hooks []OnRetryFunc) Option + func WaitTime(value time.Duration) Option + type Options struct + type PreRequestHook func(*Client, *http.Request) (*http.Request, error) + type RedirectPolicy interface + Apply func(req *http.Request, via []*http.Request) error + func DomainCheckRedirectPolicy(hostnames ...string) RedirectPolicy + func FlexibleRedirectPolicy(noOfRedirect int) RedirectPolicy + func NoRedirectPolicy() RedirectPolicy + type RedirectPolicyFunc func(*http.Request, []*http.Request) error + func (f RedirectPolicyFunc) Apply(req *http.Request, via []*http.Request) error + type Request struct + Attempt int + AuthScheme string + Body interface{} + Cookies []*http.Cookie + Error interface{} + FormData url.Values + Header http.Header + Method string + QueryParam url.Values + RawRequest *http.Request + Result interface{} + SRV *SRVRecord + Time time.Time + Token string + URL string + UserInfo *User + func (r *Request) Context() context.Context + func (r *Request) Delete(url string) (*Response, error) + func (r *Request) EnableTrace() *Request + func (r *Request) Execute(method, url string) (*Response, error) + func (r *Request) ExpectContentType(contentType string) *Request + func (r *Request) ForceContentType(contentType string) *Request + func (r *Request) Get(url string) (*Response, error) + func (r *Request) Head(url string) (*Response, error) + func (r *Request) Options(url string) (*Response, error) + func (r *Request) Patch(url string) (*Response, error) + func (r *Request) Post(url string) (*Response, error) + func (r *Request) Put(url string) (*Response, error) + func (r *Request) Send() (*Response, error) + func (r *Request) SetAuthScheme(scheme string) *Request + func (r *Request) SetAuthToken(token string) *Request + func (r *Request) SetBasicAuth(username, password string) *Request + func (r *Request) SetBody(body interface{}) *Request + func (r *Request) SetContentLength(l bool) *Request + func (r *Request) SetContext(ctx context.Context) *Request + func (r *Request) SetCookie(hc *http.Cookie) *Request + func (r *Request) SetCookies(rs []*http.Cookie) *Request + func (r *Request) SetDoNotParseResponse(parse bool) *Request + func (r *Request) SetError(err interface{}) *Request + func (r *Request) SetFile(param, filePath string) *Request + func (r *Request) SetFileReader(param, fileName string, reader io.Reader) *Request + func (r *Request) SetFiles(files map[string]string) *Request + func (r *Request) SetFormData(data map[string]string) *Request + func (r *Request) SetFormDataFromValues(data url.Values) *Request + func (r *Request) SetHeader(header, value string) *Request + func (r *Request) SetHeaderVerbatim(header, value string) *Request + func (r *Request) SetHeaders(headers map[string]string) *Request + func (r *Request) SetJSONEscapeHTML(b bool) *Request + func (r *Request) SetMultipartField(param, fileName, contentType string, reader io.Reader) *Request + func (r *Request) SetMultipartFields(fields ...*MultipartField) *Request + func (r *Request) SetMultipartFormData(data map[string]string) *Request + func (r *Request) SetOutput(file string) *Request + func (r *Request) SetPathParam(param, value string) *Request + func (r *Request) SetPathParams(params map[string]string) *Request + func (r *Request) SetQueryParam(param, value string) *Request + func (r *Request) SetQueryParams(params map[string]string) *Request + func (r *Request) SetQueryParamsFromValues(params url.Values) *Request + func (r *Request) SetQueryString(query string) *Request + func (r *Request) SetResult(res interface{}) *Request + func (r *Request) SetSRV(srv *SRVRecord) *Request + func (r *Request) TraceInfo() TraceInfo + type RequestLog struct + Body string + Header http.Header + type RequestLogCallback func(*RequestLog) error + type RequestMiddleware func(*Client, *Request) error + type Response struct + RawResponse *http.Response + Request *Request + func (r *Response) Body() []byte + func (r *Response) Cookies() []*http.Cookie + func (r *Response) Error() interface{} + func (r *Response) Header() http.Header + func (r *Response) IsError() bool + func (r *Response) IsSuccess() bool + func (r *Response) Proto() string + func (r *Response) RawBody() io.ReadCloser + func (r *Response) ReceivedAt() time.Time + func (r *Response) Result() interface{} + func (r *Response) Size() int64 + func (r *Response) Status() string + func (r *Response) StatusCode() int + func (r *Response) String() string + func (r *Response) Time() time.Duration + type ResponseError struct + Err error + Response *Response + func (e *ResponseError) Error() string + func (e *ResponseError) Unwrap() error + type ResponseLog struct + Body string + Header http.Header + type ResponseLogCallback func(*ResponseLog) error + type ResponseMiddleware func(*Client, *Response) error + type RetryAfterFunc func(*Client, *Response) (time.Duration, error) + type RetryConditionFunc func(*Response, error) bool + type SRVRecord struct + Domain string + Service string + type TraceInfo struct + ConnIdleTime time.Duration + ConnTime time.Duration + DNSLookup time.Duration + IsConnReused bool + IsConnWasIdle bool + RemoteAddr net.Addr + RequestAttempt int + ResponseTime time.Duration + ServerTime time.Duration + TCPConnTime time.Duration + TLSHandshake time.Duration + TotalTime time.Duration + type User struct + Password string + Username string Other modules containing this package github.com/hhy5861/resty