Полный продовый фикс HY2XS/Hysteria2: auth DTO, валидация bind, smoke, URI, preflight и env-контракт

This commit is contained in:
2026-05-08 05:06:29 +05:00
parent 4b382d6ef9
commit d2898ac10c
10 changed files with 49 additions and 23 deletions
+7 -2
View File
@@ -26,12 +26,17 @@ func validateStr(f validator.FieldLevel) bool {
}
func validateField[T interface{}](c *gin.Context, field T) (T, error) {
var bindErr error
if c.Request.Method == http.MethodGet {
_ = c.ShouldBindQuery(&field)
bindErr = c.ShouldBindQuery(&field)
} else if c.Request.Method == http.MethodPost ||
c.Request.Method == http.MethodPut ||
c.Request.Method == http.MethodDelete {
_ = c.ShouldBindJSON(&field)
bindErr = c.ShouldBindJSON(&field)
}
if bindErr != nil {
vo.Fail(constant.InvalidError, c)
return field, fmt.Errorf(constant.InvalidError)
}
if err := validate.Struct(&field); err != nil {
vo.Fail(constant.InvalidError, c)