Documentation ¶
Index ¶
- func Get(url string, headers, params map[string]string, timeout int64) ([]byte, error)
- func GetJSON(url string, headers, params map[string]string, timeout int64, out interface{}) error
- func GetRetry(url string, headers, params map[string]string, timeout int64, ...) ([]byte, error)
- func GetString(url string, headers, params map[string]string, timeout int64) (string, error)
- func Post(url string, headers, params, body map[string]string, timeout int64) ([]byte, error)
- func PostJSON(url string, headers, params map[string]string, timeout int64, out interface{}) error
- func PostRetry(url string, headers, params, body map[string]string, timeout int64, ...) ([]byte, error)
- func PostString(url string, headers, params map[string]string, timeout int64) (string, error)
- func SetDisableKeepAlives(enable bool)
- func SetMaxIdleConnsPerHost(count int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get GET 请求,包含超时时间 params 添加到 url 上 timeout 超时时间,秒 eg: url := "https://www.keylala.cn" params := map[string]string{"name": "Alex", "id": "1001"} Get(url, nil, params, 5)
func GetJSON ¶
GetJSON GET 请求,包含超时时间,结果转为 JSON params 添加到 url 上 timeout 超时时间,秒 out 结果写入于此,可以是 nil,指针
func GetRetry ¶
func GetRetry(url string, headers, params map[string]string, timeout int64, retryCount, sleep uint) ([]byte, error)
GetRetry GET 请求,包含超时时间,重试次数 timeout 超时时间,秒 retryCount 重试次数 sleep 重试之间 sleep 时间,毫秒 eg: url := "https://www.keylala.cn"
每次请求超时时间为 5 秒 如果请求失败,则重试,直到 3 次为止 每次重试之间 Sleep 500 毫秒 GetRetry(url, nil, nil, 5, 3, 500)
func GetString ¶
GetString GET 请求,包含超时时间,结果转为字符串 params 添加到 url 上 timeout 超时时间,秒 eg: url := "https://www.keylala.cn" GetString(url, nil, nil, 5)
func Post ¶
Post POST 请求(JSON 格式),包含超时时间 params 添加到 url 上 body 添加到 body 上 timeout 超时时间,秒 eg: url := "https://www.keylala.cn" params := map[string]string{"name": "Alex", "id": "1001"} Post(url, nil, params, 5)
func PostJSON ¶
PostJSON POST 请求,包含超时时间,结果转为 JSON params 添加到 url 上 timeout 超时时间,秒 out 结果写入于此,可以是 nil,指针
func PostRetry ¶
func PostRetry(url string, headers, params, body map[string]string, timeout int64, retryCount, sleep uint) ([]byte, error)
PostRetry POST 请求,包含超时时间,重试次数 timeout 超时时间,秒 eg: url := "https://www.keylala.cn"
每次请求超时时间为 5 秒 如果请求失败,则重试,直到 3 次为止 每次重试之间 Sleep 500 毫秒 PostRetry(url, nil, nil, 5, 3, 500)
func PostString ¶
PostString POST 请求,包含超时时间,结果转为字符串 params 添加到 url 上 timeout 超时时间,秒 eg: url := "https://www.keylala.cn" PostString(url, nil, nil, 5)
func SetDisableKeepAlives ¶
func SetDisableKeepAlives(enable bool)
SetDisableKeepAlives 设置 defaultDisableKeepAlives
func SetMaxIdleConnsPerHost ¶
func SetMaxIdleConnsPerHost(count int)
SetMaxIdleConnsPerHost 设置 defaultMaxIdleConnsPerHost
Types ¶
This section is empty.