A golang package for http routing, inspired by labstack's Echo and Rust rocket
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
577 B

package router
import (
"encoding/json"
"net/http"
)
func defaultNotFoundHandler(c *Context) error {
return c.StatusText(http.StatusNotFound)
}
func defaultMethodNotAllowedHandler(c *Context) error {
return c.StatusText(http.StatusMethodNotAllowed)
}
func defaultErrorHandler(c *Context, err interface{}) {
_ = c.StatusText(http.StatusInternalServerError)
}
func defaultReader(c *Context, dst interface{}) (bool, error) {
err := json.NewDecoder(c.Request.Body).Decode(dst)
if err != nil {
return false, c.StatusText(http.StatusBadRequest)
}
return true, nil
}