refactor: http request binding (#38971)

Better than before, still not good enough (more work can be done in the
future)

And add the missing error handling in the PrivateContext "bind"
middleware.

By the way, picked some "TrimSpace" changes from "fix: trim whitespace
from SMTP address and port - #38934" (fix #38926)
This commit is contained in:
wxiaoguang
2026-08-19 14:15:42 +08:00
committed by GitHub
parent 6c425fae6e
commit 6904f6480c
21 changed files with 265 additions and 419 deletions
+1 -7
View File
@@ -4,20 +4,14 @@
package structs
import (
"net/http"
"gitea.dev/modules/reqctx"
"gitea.dev/modules/translation/i18n"
"gitea.com/go-chi/binding"
"gitea.com/go-chi/binding" //nolint:depguard // avoid cycle import
)
// ValidateContext is a special context for form validation middleware
type ValidateContext struct {
Locale i18n.LocaleTranslation
Data reqctx.ContextData
Req *http.Request
Resp http.ResponseWriter
}
type FormDefaultValidator struct{}