Browse Source

update jsonutil

marion 4 years ago
parent
commit
32990f9563
1 changed files with 3 additions and 5 deletions
  1. 3 5
      utils/http_middleware/gin_recovery.go

+ 3 - 5
utils/http_middleware/gin_recovery.go

@@ -4,7 +4,6 @@ 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"
@@ -69,8 +68,8 @@ func Recovery(hostPrefix string, logger *logger.Logger) gin.HandlerFunc {
 					}
 					if i, ok := ctxt.Get(IsLogHTTPResponse); ok {
 						if isLogHttpResponse, ok := i.(bool); ok && isLogHttpResponse {
-							respStr, _ := jsonutil.MarshalToString(res)
-							logger = logger.WithField("responseBody", respStr)
+							respData, _ := res.MarshalJSON()
+							logger = logger.WithField("responseBody", string(respData))
 						}
 					}
 					logger.
@@ -86,8 +85,7 @@ 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 {
-							respStr, _ := jsonutil.MarshalToString(res)
-							logger = logger.WithField("responseBody", respStr)
+							logger = logger.WithField("responseBody", `{"head":{"errcode":9999,"errmsg":"未定义"}}`)
 						}
 					}
 					logger.