Skip to content

Commit

Permalink
Merge pull request #136 from Tibz-Dankan/refactor/dir-structure
Browse files Browse the repository at this point in the history
feat: add custom not found route handler
  • Loading branch information
Tibz-Dankan authored Aug 20, 2024
2 parents a965433 + 7066367 commit 03301a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/routes/notFound.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package routes

import (
"net/http"

"github.com/Tibz-Dankan/keep-active/internal/services"
"github.com/gorilla/mux"
)

func notFound(w http.ResponseWriter, r *http.Request) {
message := "Endpoint " + "'" + r.URL.Path + "'" + " does not exist!"
services.AppError(message, 404, w)
}

func NotFoundRoute(router *mux.Router) {
router.NotFoundHandler = http.HandlerFunc(notFound)
}
3 changes: 3 additions & 0 deletions internal/routes/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ func AppRouter() *mux.Router {
// Monitor route
monitor.GetMetrics(router)

// Not found route
NotFoundRoute(router)

return router
}

0 comments on commit 03301a7

Please sign in to comment.