router/default.go

30 lines
535 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"
2018-10-09 18:07:43 +02:00
"fmt"
)
func defaultNotFoundHandler(c *Context) error {
return c.String(404, `not found`)
}
func defaultMethodNotAllowedHandler(c *Context) error {
return c.String(504, `method not allowed`)
}
func defaultErrorHandler(c *Context, err interface{}) {
fmt.Println(err)
c.String(500, `internal server error`)
}
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
}