Documentation ¶
Index ¶
- Constants
- func BehaviorIsAccess(koalaUrl string) (isAccess bool, err error)
- 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 GetHttpClient(url string) (*http.Client, 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 PublicRequire(url, method string, ReqByte []byte, header http.Header, hc gin.HandlersChain, ...) (resBody []byte, resCode int, err error)
- func PublicRequireByGet(url string, header http.Header) (resBody []byte, resCode int, err error)
- func PublicRequireByGetWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
- func PublicRequireByPUT(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
- func PublicRequireByPUTWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
- func PublicRequireByPost(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
- func PublicRequireByPostForm(url string, header http.Header, urlV url.Values) (resBody []byte, resCode int, err error)
- func PublicRequireByPostFormWithoutLog(url string, header http.Header, urlV url.Values) (resBody []byte, resCode int, err error)
- func PublicRequireByPostWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, 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)
- func RetProxyLog(header http.Header, resCode int, timeNow time.Time, method string, url string, ...)
- 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 PublicProxyLog
- 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 ¶
func BehaviorIsAccess ¶ added in v1.2.5
func PublicRequire ¶
func PublicRequire(url, method string, ReqByte []byte, header http.Header, hc gin.HandlersChain, c *gin.Context) (resBody []byte, resCode int, err error)
反向代理
func PublicRequireByGet ¶
反向代理 GET
func PublicRequireByGetWithoutLog ¶ added in v1.4.5
func PublicRequireByGetWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
反向代理 GET, 不产生反向代理日志,url为网关api中登记的接口才可调用
func PublicRequireByPUT ¶
func PublicRequireByPUT(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
反向代理 PUT
func PublicRequireByPUTWithoutLog ¶ added in v1.4.16
func PublicRequireByPUTWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
反向代理 PUT,不产生反向代理日志,url为网关api中登记的接口才可调用
func PublicRequireByPost ¶
func PublicRequireByPost(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
反向代理 POST
func PublicRequireByPostForm ¶
func PublicRequireByPostForm(url string, header http.Header, urlV url.Values) (resBody []byte, resCode int, err error)
反向代理 POST 传入内容为表单
func PublicRequireByPostFormWithoutLog ¶ added in v1.4.16
func PublicRequireByPostFormWithoutLog(url string, header http.Header, urlV url.Values) (resBody []byte, resCode int, err error)
反向代理 POST 传入内容为表单,不产生反向代理日志,url为网关api中登记的接口才可调用
func PublicRequireByPostWithoutLog ¶ added in v1.4.5
func PublicRequireByPostWithoutLog(url string, header http.Header, reqByte []byte) (resBody []byte, resCode int, err error)
反向代理 POST, 不产生反向代理日志,url为网关api中登记的接口才可调用
Types ¶
type AlarmObject ¶
type AlarmVerify ¶
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 PublicProxyLog ¶ added in v1.2.2
type PublicProxyLog struct { Status int `gorm:"column:status;type:int(3);not null;comment:'http状态码'" json:"status"` // http状态码 Method string `gorm:"column:method;type:varchar(32);not null;comment:'http方法'" json:"method"` // http方法 URL string `gorm:"column:url;type:varchar(255);not null;comment:'路径'" json:"url"` // 路径 Header string `gorm:"column:header;type:varchar(255);not null;comment:'请求头'" json:"header"` // 请求头 Body string `gorm:"column:body;type:text;default:null;comment:'请求body信息'" json:"body"` // 请求body信息 ResInfo string `gorm:"column:res_info;type:text;not null;comment:'返回信息'" json:"res_info"` // 返回信息 ResErr string `gorm:"column:res_err;type:text;default:null" json:"res_err"` Latency int `gorm:"column:latency;type:int(32);not null;comment:'延迟(单位:毫秒)'" json:"latency"` // 延迟(单位:毫秒) }
PublicProxyLog [...]
func NewProxyLog ¶ added in v1.2.2
func NewProxyLog(status, latency int, method, url, header, resInfo, body, resErr string) PublicProxyLog
type RetryVerify ¶
RetryVerify Verify parse the body and verify that it is correct
Click to show internal directories.
Click to hide internal directories.