作者 yangfu

chore: log api

... ... @@ -16,7 +16,7 @@ type MessageCode struct {
Msg string `json:"msg"`
}
//Response 统一消息返回格式
// Response 统一消息返回格式
type Response struct {
MessageCode
Data rawjson.RawMessage `json:"data"`
... ... @@ -115,6 +115,7 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
var result Response
err = json.Unmarshal(byteResult, &result)
if err != nil {
gateway.InterceptSimple(requestParam.Url, string(byteResult))
return err
}
if result.Code != 0 && len(result.Msg) > 0 {
... ... @@ -123,6 +124,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
return gateway.GetResponseData(result, val)
}
func (gateway BaseServiceGateway) InterceptSimple(url string, data string) {
if gateway.Interceptor != nil {
gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v", url,
data,
))
}
}
func (gateway BaseServiceGateway) Host() string {
return gateway.host
}
... ...