yjp 1 rok temu
rodzic
commit
21d834ec20
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      gin_logger.go

+ 2 - 2
gin_logger.go

@@ -16,10 +16,10 @@ func GinLogger() gin.HandlerFunc {
 		UTC:        true,
 		TimeFormat: time.RFC3339,
 		Context: func(c *gin.Context) []zapcore.Field {
-			var body []byte
 			var buf bytes.Buffer
 
-			body, err := io.ReadAll(c.Request.Body)
+			tee := io.TeeReader(c.Request.Body, &buf)
+			body, err := io.ReadAll(tee)
 			if err != nil {
 				return make([]zapcore.Field, 0)
 			}