Documentation ¶
Index ¶
- Constants
- func Delete(url string, form httpURL.Values, options ...Option) (body []byte, err error)
- func Get(url string, form httpURL.Values, options ...Option) (body []byte, err error)
- func PatchFrom(url string, form httpURL.Values, options ...Option) (body []byte, err error)
- func PatchJSON(url string, raw json.RawMessage, options ...Option) (body []byte, err error)
- func PostForm(url string, form httpURL.Values, options ...Option) (body []byte, err error)
- func PostJSON(url string, raw json.RawMessage, options ...Option) (body []byte, err error)
- func PutForm(url string, form httpURL.Values, options ...Option) (body []byte, err error)
- func PutJSON(url string, raw json.RawMessage, options ...Option) (body []byte, err error)
- type AlarmObject
- type AlarmVerify
- type Mock
- type Option
- func WithHeader(key, value string) Option
- func WithLogger(logger *zap.Logger) Option
- func WithMock(m Mock) Option
- func WithOnFailedAlarm(alarmTitle string, alarmObject AlarmObject, alarmVerify AlarmVerify) Option
- func WithOnFailedRetry(retryTimes int, retryDelay time.Duration, retryVerify RetryVerify) Option
- func WithTTL(ttl time.Duration) Option
- func WithTrace(t trace.T) 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 ¶
This section is empty.
Functions ¶
Types ¶
type AlarmObject ¶
type AlarmVerify ¶
Verify parse the body and verify that it is correct
type Option ¶
type Option func(*option)
Option 自定义设置http请求
func WithHeader ¶
WithHeader 设置http header,可以调用多次设置多对key-value
func WithOnFailedAlarm ¶
func WithOnFailedAlarm(alarmTitle string, alarmObject AlarmObject, alarmVerify AlarmVerify) Option
WithOnFailedAlarm 设置告警通知
func WithOnFailedRetry ¶
func WithOnFailedRetry(retryTimes int, retryDelay time.Duration, retryVerify RetryVerify) Option
WithOnFailedRetry 设置失败重试
type ReplyErr ¶ added in v1.2.1
ReplyErr 错误响应,当 resp.StatusCode != http.StatusOK 时用来包装返回的 httpcode 和 body 。
func ToReplyErr ¶ added in v1.2.1
ToReplyErr 尝试将 err 转换为 ReplyErr
type RetryVerify ¶
Verify parse the body and verify that it is correct
Click to show internal directories.
Click to hide internal directories.