Fix error reponses

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-21 10:01:13 +08:00
parent b7e6009706
commit 4ac5b1c101
7 changed files with 28 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package middleware
import (
"bytes"
"encoding/json"
"io"
"log/slog"
"time"
@@ -17,6 +18,8 @@ func GinLogger() gin.HandlerFunc {
c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
}
headerJSON, _ := json.Marshal(c.Request.Header)
startTime := time.Now()
c.Next()
@@ -33,6 +36,7 @@ func GinLogger() gin.HandlerFunc {
"ip", c.ClientIP(),
"latency", time.Since(startTime).String(),
"user_agent", c.Request.UserAgent(),
"headers", string(headerJSON),
"request_body", string(body),
"errors", errorMessage,
}