收敛 JSON 请求解析测试实现

This commit is contained in:
xuans 2026-08-30 20:12:33 +08:00
parent be84ecfb91
commit 5f7930ce35
2 changed files with 0 additions and 9 deletions

View File

@ -11,8 +11,6 @@ import (
)
func TestBindJSONRejectsUnknownFieldsAndTrailingValues(t *testing.T) {
t.Parallel()
tests := []struct {
name string
body string

View File

@ -93,13 +93,6 @@ func (s *Server) sameOriginForAPI(request *http.Request) bool {
return strings.EqualFold(parsed.Host, request.Host) && strings.EqualFold(parsed.Scheme, requestScheme)
}
func limitJSONBody(c *gin.Context) {
if c == nil || c.Request == nil || c.Request.Body == nil {
return
}
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, jsonRequestBodyLimit)
}
func requestIDFromContext(c *gin.Context) string {
value, exists := c.Get("request_id")
if !exists {