Documentation ¶
Overview ¶
Copyright (c) 2015-2021 Jeevanandam M (jeeva@myjeeva.com), All rights reserved. resty source code and usage is governed by a MIT style license that can be found in the LICENSE file.
Index ¶
- Variables
- func Backoff(operation func() (*Response, error), options ...Option) error
- func BuildCurlRequest(req *http.Request, args ...interface{}) (curl string)
- func BuildRequest(method string, origurl string, args ...interface{}) (req *http.Request, err error)
- func IoCaptureOutput(f func()) string
- func NewHttpClient() *http.Client
- func SetRespHandler(fn func(*Response) error)
- type Auth
- type ContentType
- type Datas
- type Files
- type FormData
- type Header
- type Json
- type Jsoni
- type OnRetryFunc
- type Option
- type Options
- type Params
- type ParamsArray
- type Response
- func BuildResponse(response *http.Response) *Response
- func Delete(origurl string, args ...interface{}) (resp *Response, err error)
- func Get(origurl string, args ...interface{}) (resp *Response, err error)
- func Patch(origurl string, args ...interface{}) (resp *Response, err error)
- func Post(origurl string, args ...interface{}) (resp *Response, err error)
- func Put(origurl string, args ...interface{}) (resp *Response, err error)
- func (resp *Response) Body() []byte
- func (resp *Response) Cookies() (cookies []*http.Cookie)
- func (resp *Response) GetCookie(key string) (val string)
- func (resp *Response) GetDumpCurl() string
- func (resp *Response) GetDumpResponse() string
- func (resp *Response) GetReq() (req *http.Request)
- func (resp *Response) HasCookie(key string) (exists bool)
- func (resp *Response) Header() http.Header
- func (resp *Response) Json(v interface{}) error
- func (resp *Response) RaiseForStatus() (code int, err error)
- func (resp *Response) ResponseDebug()
- func (resp *Response) SaveFile(filename string) error
- func (resp *Response) SetClientReq(req *http.Request, client *http.Client) *Response
- func (resp *Response) SetDoNotCloseBody() *Response
- func (resp *Response) SetStartEndTime(start, end time.Time) *Response
- func (resp *Response) Size() int
- func (resp *Response) StatusCode() (code int)
- func (resp *Response) Text() string
- func (resp *Response) Time() time.Duration
- type RetryConditionFunc
- type Session
- func (session *Session) BuildRequest(method, origurl string, args ...interface{}) (*http.Request, error)
- func (session *Session) ClearCookies()
- func (session *Session) Clone() *Session
- func (session *Session) Close()
- func (session *Session) DelGlobalHeader(key string) *Session
- func (session *Session) Delete(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) DisableDebug() *Session
- func (session *Session) Get(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) GetGlobalHeader() map[string]string
- func (session *Session) GetTransport() *http.Transport
- func (session *Session) Patch(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) Post(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) Put(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) RequestDebug() string
- func (session *Session) Run(origurl string, args ...interface{}) (resp *Response, err error)
- func (session *Session) SetContext(ctx context.Context) *Session
- func (session *Session) SetCookie(cookie *http.Cookie) *Session
- func (session *Session) SetDebug() *Session
- func (session *Session) SetDebugBody() *Session
- func (session *Session) SetDoNotCloseBody(flag bool) *Session
- func (session *Session) SetGlobalHeader(key, value string) *Session
- func (session *Session) SetHeader(key, value string) *Session
- func (session *Session) SetMethod(method string) *Session
- func (session *Session) SetProxy(proxyurl string) *Session
- func (session *Session) SetRespHandler(fn func(*Response) error) *Session
- func (session *Session) SetRetryCondition(fn func(*Response, error) bool) *Session
- func (session *Session) SetRetryCount(count int) *Session
- func (session *Session) SetRetryWaitTime(waitTime time.Duration) *Session
- func (session *Session) SetRootCertificate(caPemPath string) *Session
- func (session *Session) SetTimeout(n time.Duration) *Session
- func (session *Session) SetTransport(tsp *http.Transport) *Session
- func (session *Session) SkipSsl(v bool) *Session
- type TraceInfo
Constants ¶
This section is empty.
Variables ¶
var VERSION string = "v0.0.0"
Functions ¶
func Backoff ¶ added in v1.0.24
Backoff retries with increasing timeout duration up until X amount of retries (Default is 3 attempts, Override with option Retries(n))
func BuildCurlRequest ¶ added in v0.1.17
func BuildRequest ¶
func BuildRequest(method string, origurl string, args ...interface{}) (req *http.Request, err error)
BuildRequest -
func IoCaptureOutput ¶ added in v1.0.12
func IoCaptureOutput(f func()) string
func NewHttpClient ¶ added in v1.0.9
func SetRespHandler ¶
Types ¶
type ContentType ¶ added in v0.2.0
type ContentType string
type AnyData interface{} // for AnyData
const ( ContentTypeNone ContentType = "" ContentTypeFormEncode ContentType = "application/x-www-form-urlencoded" ContentTypeFormData ContentType = "multipart/form-data" ContentTypeJson ContentType = "application/json" ContentTypePlain ContentType = "text/plain" )
type OnRetryFunc ¶ added in v1.0.24
OnRetryFunc is for side-effecting functions triggered on retry
type Option ¶ added in v1.0.24
type Option func(*Options)
Option is to create convenient retry options like wait time, max retries, etc.
func MaxWaitTime ¶ added in v1.0.24
MaxWaitTime sets the max wait time to sleep between requests
func RetryConditions ¶ added in v1.0.24
func RetryConditions(conditions []RetryConditionFunc) Option
RetryConditions sets the conditions that will be checked for retry.
type Options ¶ added in v1.0.24
type Options struct {
// contains filtered or unexported fields
}
Options struct is used to hold retry settings.
type ParamsArray ¶ added in v1.0.21
type Response ¶
type Response struct { R *http.Response Attempt int TraceInfo *TraceInfo // contains filtered or unexported fields }
func BuildResponse ¶ added in v1.0.9
func (*Response) GetDumpCurl ¶ added in v1.0.13
func (*Response) GetDumpResponse ¶ added in v1.0.13
func (*Response) RaiseForStatus ¶ added in v1.0.3
func (*Response) ResponseDebug ¶
func (resp *Response) ResponseDebug()
func (*Response) SetClientReq ¶ added in v1.0.10
func (*Response) SetDoNotCloseBody ¶ added in v1.0.35
func (*Response) SetStartEndTime ¶ added in v1.0.9
func (*Response) StatusCode ¶ added in v1.0.3
type RetryConditionFunc ¶ added in v1.0.24
RetryConditionFunc type is for retry condition function input: non-nil Response OR request execution error
type Session ¶
func R ¶ added in v1.0.8
func R() *Session
New request session @params method GET|POST|PUT|DELETE|PATCH
func (*Session) BuildRequest ¶
func (session *Session) BuildRequest(method, origurl string, args ...interface{}) (*http.Request, error)
BuildRequest
func (*Session) ClearCookies ¶
func (session *Session) ClearCookies()
func (*Session) DelGlobalHeader ¶ added in v1.0.11
Del global header
func (*Session) DisableDebug ¶ added in v1.0.8
func (*Session) GetGlobalHeader ¶ added in v1.0.11
Get global header
func (*Session) GetTransport ¶ added in v1.0.30
func (*Session) RequestDebug ¶
func (*Session) SetContext ¶ added in v1.0.29
func (*Session) SetDebugBody ¶ added in v1.0.12
func (*Session) SetDoNotCloseBody ¶ added in v1.0.35
func (*Session) SetGlobalHeader ¶ added in v1.0.11
Set global header
func (*Session) SetRespHandler ¶
func (*Session) SetRetryCondition ¶ added in v1.0.24
func (*Session) SetRetryCount ¶ added in v1.0.24
func (*Session) SetRetryWaitTime ¶ added in v1.0.24
func (*Session) SetRootCertificate ¶ added in v1.0.33
In generally, you could SystemCertPool instead of NewCertPool to keep existing certs.
func (*Session) SetTimeout ¶
set timeout s = second
func (*Session) SetTransport ¶ added in v1.0.30
type TraceInfo ¶ added in v1.0.29
type TraceInfo struct { // DNSLookup is a duration that transport took to perform // DNS lookup. DNSLookup time.Duration // ConnTime is a duration that took to obtain a successful connection. ConnTime time.Duration // TCPConnTime is a duration that took to obtain the TCP connection. TCPConnTime time.Duration // TLSHandshake is a duration that TLS handshake took place. TLSHandshake time.Duration // ServerTime is a duration that server took to respond first byte. ServerTime time.Duration // ResponseTime is a duration since first response byte from server to // request completion. ResponseTime time.Duration // TotalTime is a duration that total request took end-to-end. TotalTime time.Duration // IsConnReused is whether this connection has been previously // used for another HTTP request. IsConnReused bool // IsConnWasIdle is whether this connection was obtained from an // idle pool. IsConnWasIdle bool // ConnIdleTime is a duration how long the connection was previously // idle, if IsConnWasIdle is true. ConnIdleTime time.Duration // RequestAttempt is to represent the request attempt made during a Resty // request execution flow, including retry count. RequestAttempt int // RemoteAddr returns the remote network address. RemoteAddr net.Addr }
TraceInfo struct is used provide request trace info such as DNS lookup duration, Connection obtain duration, Server processing duration, etc.
Since v2.0.0
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package shellescape provides the shellescape.Quote to escape arbitrary strings for a safe use as command line arguments in the most common POSIX shells.
|
Package shellescape provides the shellescape.Quote to escape arbitrary strings for a safe use as command line arguments in the most common POSIX shells. |