forked from Fuyu/router
Add Reader
This commit is contained in:
parent
69754a9946
commit
4d46f5c770
2 changed files with 19 additions and 6 deletions
11
default.go
11
default.go
|
@ -1,6 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
|
@ -16,3 +17,13 @@ func defaultErrorHandler(c *Context, err interface{}) {
|
|||
fmt.Println(err)
|
||||
c.String(500, `internal server error`)
|
||||
}
|
||||
|
||||
func defaultReader(c *Context, dst interface{}) bool {
|
||||
err := json.NewDecoder(c.Request.Body).Decode(dst)
|
||||
if err != nil {
|
||||
c.NoContent(400)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue