2018-10-09 18:07:43 +02:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
2018-10-09 19:18:09 +02:00
|
|
|
"encoding/json"
|
2018-11-18 15:39:46 +01:00
|
|
|
"net/http"
|
2018-10-09 18:07:43 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func defaultNotFoundHandler(c *Context) error {
|
2018-11-18 15:39:46 +01:00
|
|
|
return c.StatusText(http.StatusNotFound)
|
2018-10-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func defaultMethodNotAllowedHandler(c *Context) error {
|
2018-11-18 15:39:46 +01:00
|
|
|
return c.StatusText(http.StatusMethodNotAllowed)
|
2018-10-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func defaultErrorHandler(c *Context, err interface{}) {
|
2018-11-18 15:39:46 +01:00
|
|
|
_ = c.StatusText(http.StatusInternalServerError)
|
2018-10-09 18:07:43 +02:00
|
|
|
}
|
2018-10-09 19:18:09 +02:00
|
|
|
|
2018-11-18 16:29:06 +01:00
|
|
|
func defaultReader(c *Context, dst interface{}) (bool, error) {
|
2018-10-09 19:18:09 +02:00
|
|
|
err := json.NewDecoder(c.Request.Body).Decode(dst)
|
|
|
|
if err != nil {
|
2018-11-18 16:29:06 +01:00
|
|
|
return false, c.StatusText(http.StatusBadRequest)
|
2018-10-09 19:18:09 +02:00
|
|
|
}
|
|
|
|
|
2018-11-18 16:29:06 +01:00
|
|
|
return true, nil
|
2018-10-09 19:18:09 +02:00
|
|
|
}
|