Merge branch 'master' into add-note-about-nomsgpack

This commit is contained in:
Bo-Yi Wu 2021-05-01 13:57:40 +08:00 committed by GitHub
commit c576a68bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -941,7 +941,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})

View File

@ -6,7 +6,7 @@ package binding
import ( import (
"bytes" "bytes"
"fmt" "errors"
"io" "io"
"net/http" "net/http"
@ -32,7 +32,7 @@ func (jsonBinding) Name() string {
func (jsonBinding) Bind(req *http.Request, obj interface{}) error { func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
if req == nil || req.Body == nil { if req == nil || req.Body == nil {
return fmt.Errorf("invalid request") return errors.New("invalid request")
} }
return decodeJSON(req.Body, obj) return decodeJSON(req.Body, obj)
} }