Fix example code of Bind Uri

Need to pass a string to `gin.H` to show a message correctly.
This commit is contained in:
yuuji.yaginuma 2021-05-01 11:46:28 +09:00
parent 215c9ce231
commit b242fafdeb

View File

@ -930,7 +930,7 @@ func main() {
route.GET("/:name/:id", func(c *gin.Context) { route.GET("/:name/:id", func(c *gin.Context) {
var person Person var person Person
if err := c.ShouldBindUri(&person); err != nil { if err := c.ShouldBindUri(&person); err != nil {
c.JSON(400, gin.H{"msg": err}) c.JSON(400, gin.H{"msg": err.Error()})
return return
} }
c.JSON(200, gin.H{"name": person.Name, "uuid": person.ID}) c.JSON(200, gin.H{"name": person.Name, "uuid": person.ID})