router/default.go

29 lines
545 B
Go
Raw Normal View History

2018-10-09 18:07:43 +02:00
package router
import (
2018-10-09 19:18:09 +02:00
"encoding/json"
"net/http"
2018-10-09 18:07:43 +02:00
)
func defaultNotFoundHandler(c *Context) error {
return c.StatusText(http.StatusNotFound)
2018-10-09 18:07:43 +02:00
}
func defaultMethodNotAllowedHandler(c *Context) error {
return c.StatusText(http.StatusMethodNotAllowed)
2018-10-09 18:07:43 +02:00
}
func defaultErrorHandler(c *Context, err interface{}) {
_ = c.StatusText(http.StatusInternalServerError)
2018-10-09 18:07:43 +02:00
}
2018-10-09 19:18:09 +02:00
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
}