fix: 加密中间件对GET请求空body返回400的问题

This commit is contained in:
Trae AI
2026-06-21 16:22:05 +08:00
parent 69d7b71995
commit 0a7392f30d
+3
View File
@@ -46,6 +46,8 @@ func (cm *CryptoMiddleware) ProcessRequest() gin.HandlerFunc {
return
}
// 空请求体(如 GET 请求),跳过解析,直接放行
if len(body) > 0 {
var req interface{}
if err := json.Unmarshal(body, &req); err != nil {
c.JSON(400, gin.H{"code": 400, "message": "解析请求体失败"})
@@ -76,6 +78,7 @@ func (cm *CryptoMiddleware) ProcessRequest() gin.HandlerFunc {
}
}
}
}
c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
}