diff --git a/japicore/miscRouteHandling.go b/japicore/miscRouteHandling.go index 964c2fb..15426e5 100644 --- a/japicore/miscRouteHandling.go +++ b/japicore/miscRouteHandling.go @@ -18,6 +18,13 @@ func Handler() bunrouter.HandlerFunc { } } +func RouteNotFoundHandler() bunrouter.HandlerFunc { + return func(w http.ResponseWriter, req bunrouter.Request) error { + warning := fmt.Sprintf("%s is not an availble route", req.URL.Path) + return jutils.ProcessCustomHttpError("MethodNotAllowedHandler", warning, 404, w) + } +} + func MethodNotAllowedHandler() bunrouter.HandlerFunc { return func(w http.ResponseWriter, req bunrouter.Request) error { warning := fmt.Sprintf("%s method not availble for \"%s\"", req.URL.Path, req.Method) diff --git a/main.go b/main.go index 93a1cda..08b2dfe 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ func main() { router := bunrouter.New( bunrouter.WithMethodNotAllowedHandler(japicore.MethodNotAllowedHandler()), + bunrouter.WithNotFoundHandler(japicore.RouteNotFoundHandler()), ) group := router.NewGroup("")