marion 4 роки тому
батько
коміт
a9c2974199
1 змінених файлів з 5 додано та 4 видалено
  1. 5 4
      utils/http_middleware/gin_recovery.go

+ 5 - 4
utils/http_middleware/gin_recovery.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"git.aionnect.com/aionnect/go-common/utils"
 	"git.aionnect.com/aionnect/go-common/utils/date"
+	"git.aionnect.com/aionnect/go-common/utils/jsonutil"
 	"git.aionnect.com/aionnect/go-common/utils/logger"
 	"github.com/gin-gonic/gin"
 	"net/http"
@@ -68,8 +69,8 @@ func Recovery(hostPrefix string, logger *logger.Logger) gin.HandlerFunc {
 					}
 					if i, ok := ctxt.Get(IsLogHTTPResponse); ok {
 						if isLogHttpResponse, ok := i.(bool); ok && isLogHttpResponse {
-							respB, _ := res.MarshalJSON()
-							logger = logger.WithField("responseBody", string(respB))
+							respStr, _ := jsonutil.MarshalToString(res)
+							logger = logger.WithField("responseBody", respStr)
 						}
 					}
 					logger.
@@ -85,8 +86,8 @@ func Recovery(hostPrefix string, logger *logger.Logger) gin.HandlerFunc {
 					res := utils.E(9999, "未定义", nil)
 					if i, ok := ctxt.Get(IsLogHTTPResponse); ok {
 						if isLogHttpResponse, ok := i.(bool); ok && isLogHttpResponse {
-							respB, _ := res.MarshalJSON()
-							logger = logger.WithField("responseBody", string(respB))
+							respStr, _ := jsonutil.MarshalToString(res)
+							logger = logger.WithField("responseBody", respStr)
 						}
 					}
 					logger.