清理一些无效代码
This commit is contained in:
@ -101,14 +101,11 @@ func NewHttpClient(reqConfig *define.Request, reqOption *RequestOption) (*HttpCl
|
||||
}
|
||||
restyClient, restyRequest := NewRestyClient(reqConfig)
|
||||
hc := &HttpClient{
|
||||
Client: restyClient,
|
||||
request: restyRequest,
|
||||
reqOption: reqOption,
|
||||
reqCfg: reqConfig,
|
||||
http4xxHandler: make([]define.Http4xxHandler, 0),
|
||||
http5xxHandler: make([]define.Http5xxHandler, 0),
|
||||
httpBusinessErrorHandler: make([]define.HttpBusinessErrorHandler, 0),
|
||||
requestFinishHandler: make([]define.RequestFinishHandler, 0),
|
||||
Client: restyClient,
|
||||
request: restyRequest,
|
||||
reqOption: reqOption,
|
||||
reqCfg: reqConfig,
|
||||
requestFinishHandler: make([]define.RequestFinishHandler, 0),
|
||||
}
|
||||
hc.OnRequestFinish(func(req *define.Request, rep *define.Response) {
|
||||
if rep.IsSuccess {
|
||||
@ -129,41 +126,10 @@ func NewHttpClient(reqConfig *define.Request, reqOption *RequestOption) (*HttpCl
|
||||
// Date : 15:27 2024/5/31
|
||||
type HttpClient struct {
|
||||
*resty.Client
|
||||
request *resty.Request
|
||||
reqOption *RequestOption
|
||||
reqCfg *define.Request
|
||||
http4xxHandler []define.Http4xxHandler
|
||||
http5xxHandler []define.Http5xxHandler
|
||||
httpBusinessErrorHandler []define.HttpBusinessErrorHandler
|
||||
requestSendErrorHandler []define.RequestSendErrorHandler
|
||||
requestFinishHandler []define.RequestFinishHandler
|
||||
}
|
||||
|
||||
// OnResponse4xx 4xx处理逻辑
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:20 2024/6/1
|
||||
func (hc *HttpClient) OnResponse4xx(handlerList ...define.Http4xxHandler) {
|
||||
hc.http4xxHandler = append(hc.http4xxHandler, handlerList...)
|
||||
}
|
||||
|
||||
// OnResponse5xx 5xx处理逻辑
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:21 2024/6/1
|
||||
func (hc *HttpClient) OnResponse5xx(handlerList ...define.Http5xxHandler) {
|
||||
hc.http5xxHandler = append(hc.http5xxHandler, handlerList...)
|
||||
}
|
||||
|
||||
// OnResponseBusinessError 业务错误出路逻辑
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:22 2024/6/1
|
||||
func (hc *HttpClient) OnResponseBusinessError(handlerList ...define.HttpBusinessErrorHandler) {
|
||||
hc.httpBusinessErrorHandler = append(hc.httpBusinessErrorHandler, handlerList...)
|
||||
request *resty.Request
|
||||
reqOption *RequestOption
|
||||
reqCfg *define.Request
|
||||
requestFinishHandler []define.RequestFinishHandler
|
||||
}
|
||||
|
||||
// OnRequestFinish 请求完成事件
|
||||
@ -175,15 +141,6 @@ func (hc *HttpClient) OnRequestFinish(handlerList ...define.RequestFinishHandler
|
||||
hc.requestFinishHandler = append(hc.requestFinishHandler, handlerList...)
|
||||
}
|
||||
|
||||
// SetRestyClient 设置client
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:54 2024/5/31
|
||||
func (hc *HttpClient) SetRestyClient(restyClient *resty.Client) {
|
||||
hc.Client = restyClient
|
||||
}
|
||||
|
||||
// GetRestyClient 获取 resty client
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
Reference in New Issue
Block a user