forked from Fuyu/router
Add error to return of Reader
This commit is contained in:
parent
4c83818ecd
commit
a16ee2740c
2 changed files with 12 additions and 8 deletions
|
@ -17,12 +17,11 @@ func defaultErrorHandler(c *Context, err interface{}) {
|
|||
_ = c.StatusText(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
func defaultReader(c *Context, dst interface{}) bool {
|
||||
func defaultReader(c *Context, dst interface{}) (bool, error) {
|
||||
err := json.NewDecoder(c.Request.Body).Decode(dst)
|
||||
if err != nil {
|
||||
c.NoContent(400)
|
||||
return false
|
||||
return false, c.StatusText(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue