mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-04 14:49:27 +08:00
Fix ShouldBindBodyWith example to use binding.JSON
binding.Form does not implement BindingBody, so the docs example could not compile or run. Use binding.JSON instead. Fixes #3296
This commit is contained in:
parent
34dac209ff
commit
909b6f36b8
@ -1582,7 +1582,7 @@ func SomeHandler(c *gin.Context) {
|
||||
objA := formA{}
|
||||
objB := formB{}
|
||||
// This reads c.Request.Body and stores the result into the context.
|
||||
if errA := c.ShouldBindBodyWith(&objA, binding.Form); errA == nil {
|
||||
if errA := c.ShouldBindBodyWith(&objA, binding.JSON); errA == nil {
|
||||
c.String(http.StatusOK, `the body should be formA`)
|
||||
// At this time, it reuses body stored in the context.
|
||||
} else if errB := c.ShouldBindBodyWith(&objB, binding.JSON); errB == nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user