Documentation ¶
Index ¶
- type HTTPClient
- func (c HTTPClient) Delete(url string, headers map[string]string, body []byte) ([]byte, error)
- func (c HTTPClient) DeleteJSON(url string, headers map[string]string, resp interface{}) error
- func (c HTTPClient) Get(url string, headers map[string]string, body []byte) ([]byte, error)
- func (c HTTPClient) GetJSON(url string, headers map[string]string, resp interface{}) error
- func (c HTTPClient) Post(url string, headers map[string]string, body []byte) ([]byte, error)
- func (c HTTPClient) PostJSON(url string, headers map[string]string, data interface{}, resp interface{}) error
- func (c HTTPClient) Put(url string, headers map[string]string, body []byte) ([]byte, error)
- func (c HTTPClient) PutJSON(url string, headers map[string]string, data interface{}, resp interface{}) error
- func (c *HTTPClient) RetryTimes(t int) *HTTPClient
- func (c *HTTPClient) SetLogger(l *log.Logger) *HTTPClient
- func (c *HTTPClient) Timeout(t int) *HTTPClient
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPClient ¶ added in v1.3.0
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient 带超时重试控制的http客户端.
func (HTTPClient) DeleteJSON ¶ added in v1.3.0
func (c HTTPClient) DeleteJSON(url string, headers map[string]string, resp interface{}) error
DeleteJSON 发送JSON格式delete请求, 并解析返回结果.
func (HTTPClient) GetJSON ¶ added in v1.3.0
func (c HTTPClient) GetJSON(url string, headers map[string]string, resp interface{}) error
GetJSON 发送Get请求, 并解析返回json.
func (HTTPClient) PostJSON ¶ added in v1.3.0
func (c HTTPClient) PostJSON(url string, headers map[string]string, data interface{}, resp interface{}) error
PostJSON 发送json结构数据请求,并解析返回结果.
func (HTTPClient) PutJSON ¶ added in v1.3.0
func (c HTTPClient) PutJSON(url string, headers map[string]string, data interface{}, resp interface{}) error
PutJSON 发送json请求解析返回结果.
func (*HTTPClient) RetryTimes ¶ added in v1.3.0
func (c *HTTPClient) RetryTimes(t int) *HTTPClient
RetryTimes 设置连接重试次数,默认为3次
func (*HTTPClient) SetLogger ¶ added in v1.3.1
func (c *HTTPClient) SetLogger(l *log.Logger) *HTTPClient
SetLogger 开启日志.
func (*HTTPClient) Timeout ¶ added in v1.3.0
func (c *HTTPClient) Timeout(t int) *HTTPClient
Timeout 设置超时时间,单位:秒, 默认300秒.
type StatusError ¶ added in v1.2.0
func (*StatusError) Error ¶ added in v1.2.0
func (se *StatusError) Error() string
Click to show internal directories.
Click to hide internal directories.