yjp 1 rok pred
rodič
commit
21d834ec20
1 zmenil súbory, kde vykonal 2 pridanie a 2 odobranie
  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)
 			}