作者 yangfu

chore: log api

@@ -16,7 +16,7 @@ type MessageCode struct { @@ -16,7 +16,7 @@ type MessageCode struct {
16 Msg string `json:"msg"` 16 Msg string `json:"msg"`
17 } 17 }
18 18
19 -//Response 统一消息返回格式 19 +// Response 统一消息返回格式
20 type Response struct { 20 type Response struct {
21 MessageCode 21 MessageCode
22 Data rawjson.RawMessage `json:"data"` 22 Data rawjson.RawMessage `json:"data"`
@@ -115,6 +115,7 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ @@ -115,6 +115,7 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
115 var result Response 115 var result Response
116 err = json.Unmarshal(byteResult, &result) 116 err = json.Unmarshal(byteResult, &result)
117 if err != nil { 117 if err != nil {
  118 + gateway.InterceptSimple(requestParam.Url, string(byteResult))
118 return err 119 return err
119 } 120 }
120 if result.Code != 0 && len(result.Msg) > 0 { 121 if result.Code != 0 && len(result.Msg) > 0 {
@@ -123,6 +124,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{ @@ -123,6 +124,14 @@ func (gateway BaseServiceGateway) DoRequest(requestParam Request, val interface{
123 return gateway.GetResponseData(result, val) 124 return gateway.GetResponseData(result, val)
124 } 125 }
125 126
  127 +func (gateway BaseServiceGateway) InterceptSimple(url string, data string) {
  128 + if gateway.Interceptor != nil {
  129 + gateway.Interceptor(fmt.Sprintf("【网关】 %v | %v \nResponse:%v", url,
  130 + data,
  131 + ))
  132 + }
  133 +}
  134 +
126 func (gateway BaseServiceGateway) Host() string { 135 func (gateway BaseServiceGateway) Host() string {
127 return gateway.host 136 return gateway.host
128 } 137 }