mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Merge 17cc6e95e68fb6e96607544562c27e7419fdf3ea into ae9f03e6e80212e45427f811683f2a512cc8f506
This commit is contained in:
commit
73a97443c0
@ -469,11 +469,11 @@ func (c *Context) BindQuery(obj interface{}) error {
|
||||
}
|
||||
|
||||
// MustBindWith binds the passed struct pointer using the specified binding engine.
|
||||
// It will abort the request with HTTP 400 if any error ocurrs.
|
||||
// It will abort the request with HTTP 422(Unprocessable Entity) if any error ocurrs.
|
||||
// See the binding package.
|
||||
func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) {
|
||||
if err = c.ShouldBindWith(obj, b); err != nil {
|
||||
c.AbortWithError(400, err).SetType(ErrorTypeBind)
|
||||
c.AbortWithError(422, err).SetType(ErrorTypeBind)
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -1224,7 +1224,7 @@ func TestContextBadAutoBind(t *testing.T) {
|
||||
|
||||
assert.Empty(t, obj.Bar)
|
||||
assert.Empty(t, obj.Foo)
|
||||
assert.Equal(t, w.Code, 400)
|
||||
assert.Equal(t, w.Code, 422)
|
||||
assert.True(t, c.IsAborted())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user