Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
- func Get(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
- func PatchFrom(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
- func PatchJSON(url string, raw json.RawMessage, options ...Option) (httpCode int, body []byte, err error)
- func PostForm(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
- func PostJSON(url string, raw json.RawMessage, options ...Option) (httpCode int, body []byte, err error)
- func PutForm(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
- func PutJSON(url string, raw json.RawMessage, options ...Option) (httpCode int, body []byte, err error)
- type Mock
- type Option
- type ReplyErr
- type RetryVerify
Constants ¶
View Source
const ( // DefaultRetryTimes 如果请求失败,最多重试3次 DefaultRetryTimes = 3 // DefaultRetryDelay 在重试前,延迟等待100毫秒 DefaultRetryDelay = time.Millisecond * 100 )
View Source
const ( // DefaultTTL 一次http请求最长执行1分钟 DefaultTTL = time.Minute )
Variables ¶
Functions ¶
func Delete ¶
func Delete(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
Delete delete 请求
func PatchFrom ¶
func PatchFrom(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
PatchFrom patch form 请求
func PatchJSON ¶
func PatchJSON(url string, raw json.RawMessage, options ...Option) (httpCode int, body []byte, err error)
PatchJSON patch json 请求
func PostForm ¶
func PostForm(url string, form httpURL.Values, options ...Option) (httpCode int, body []byte, err error)
PostForm post form 请求
func PostJSON ¶
func PostJSON(url string, raw json.RawMessage, options ...Option) (httpCode int, body []byte, err error)
PostJSON post json 请求
Types ¶
type Option ¶
type Option func(*option)
Option 自定义设置http请求
func WithHeader ¶
WithHeader 设置http header,可以调用多次设置多对key-value
func WithOnFailedRetry ¶
func WithOnFailedRetry(retryTimes int, retryDelay time.Duration, retryVerify RetryVerify) Option
WithOnFailedRetry 设置失败重试
type RetryVerify ¶
RetryVerify Verify parse the body and verify that it is correct
Click to show internal directories.
Click to hide internal directories.