client

package
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2018 License: GPL-3.0 Imports: 11 Imported by: 3

Documentation

Index

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 New

func New() *HTTPClient

New 创建一个带超时和重试控制的http client, 单位秒.

func (HTTPClient) Delete added in v1.3.0

func (c HTTPClient) Delete(url string, headers map[string]string, body []byte) ([]byte, error)

Delete 发送delete请求.

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) Get added in v1.3.0

func (c HTTPClient) Get(url string, headers map[string]string, body []byte) ([]byte, error)

Get 发送Get请求.

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) Post added in v1.3.0

func (c HTTPClient) Post(url string, headers map[string]string, body []byte) ([]byte, error)

Post 发Post请求.

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) Put added in v1.3.0

func (c HTTPClient) Put(url string, headers map[string]string, body []byte) ([]byte, error)

Put 发送put请求.

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

type StatusError struct {
	Code    int
	Message string
}

func (*StatusError) Error added in v1.2.0

func (se *StatusError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL