fix: router

This commit is contained in:
Young Xu 2024-04-06 02:13:15 +08:00
parent 28e8014aad
commit 7fe6e7077c
1 changed files with 3 additions and 2 deletions

View File

@ -345,7 +345,7 @@ func (r *Register) bindAndValidate(c *gin.Context, req interface{}) error {
return nil
}
bodyBytes, _ := io.ReadAll(c.Request.Body)
c.Request.Body.Close()
_ = c.Request.Body.Close()
c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
// 如果只有query有数据则获取query中的参数
@ -404,7 +404,8 @@ func (r *Register) bindAndValidate(c *gin.Context, req interface{}) error {
err := validate.Struct(req)
if err != nil {
if _, ok := err.(*validator.InvalidValidationError); ok {
var invalidValidationError *validator.InvalidValidationError
if errors.As(err, &invalidValidationError) {
logrus.Errorf("validate failed: %+v", err)
return err
}