Fix bind json error

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-20 19:48:59 +08:00
parent 0e7aaed154
commit 231f591767
2 changed files with 6 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ func Exchange(c *gin.Context) {
State string `json:"state"`
}
err := c.BindJSON(&exchangeReq)
err := c.ShouldBindJSON(&exchangeReq)
if err != nil {
fmt.Println(err)
utils.HttpResponse(c, 400, "", "invalid request")

View File

@@ -23,7 +23,11 @@ func Update(c *gin.Context) {
}
var ReqInfo data.User
c.BindJSON(&ReqInfo)
err = c.ShouldBindJSON(&ReqInfo)
if err != nil {
utils.HttpResponse(c, 400, "", "invilad request")
return
}
// Get user info
userData, err := new(data.User).GetByUserId(userId)