forked from mirror/gin
Fix example code of `Bind Uri` (#2710)
Need to pass a string to `gin.H` to show a message correctly.
This commit is contained in:
parent
215c9ce231
commit
1acb459c10
|
@ -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})
|
||||||
|
|
Loading…
Reference in New Issue