Merge 909b6f36b88daeeedc6278cbbc856aec09da3291 into 43fe48e8a0f44af783116cdb010725e6bb50255f

This commit is contained in:
Hashim Khan 2026-09-30 15:24:09 +05:00 committed by GitHub
commit b0daf99b10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1623,7 +1623,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 {