Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultTimeout is the default timeout per request DefaultTimeout = time.Second * 5 // DefaultRetryCount is the default retry count DefaultRetryCount = 2 // GlobalTransport is the global transport // NOTE: When using proxy, CREATE A NEW TRANSPORT to avoid affecting requests that do not need proxies. GlobalTransport = &http.Transport{ MaxIdleConns: 1000, MaxIdleConnsPerHost: 10, IdleConnTimeout: 60 * time.Second, } // DefaultClient is the default request client DefaultClient = resty.New().SetLogger(NewRestyLogger()). SetTransport(GlobalTransport). SetTimeout(DefaultTimeout). SetRetryCount(DefaultRetryCount) )
Functions ¶
func NewClient ¶
func NewClient() *resty.Client
NewClient creates a new resty client using the global transport (with timeout default to 2s and retry at most 2 times)
func NewClientWithTransport ¶
func NewClientWithTransport(tran http.RoundTripper) *resty.Client
NewClientWithTransport creates a new resty client from given transport
Types ¶
type RestyLogger ¶
type RestyLogger struct { }
RestyLogger implements resty logger
func NewRestyLogger ¶
func NewRestyLogger() *RestyLogger
func (RestyLogger) Debugf ¶
func (r RestyLogger) Debugf(format string, v ...interface{})
func (RestyLogger) Errorf ¶
func (r RestyLogger) Errorf(format string, v ...interface{})
func (RestyLogger) Warnf ¶
func (r RestyLogger) Warnf(format string, v ...interface{})
Click to show internal directories.
Click to hide internal directories.