Skip to content

Commit

Permalink
feat(controllers): add custom not found handler
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-zeman committed Aug 26, 2024
1 parent 71bb8d9 commit 85aab00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/controllers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewAPIRouter(

func (a API) mountCommonControllers(mux *http.ServeMux) {
mux.Handle("/metrics", promhttp.Handler())
mux.HandleFunc("/", NotFound)
}

func (a API) mountTodoControllers(mux *http.ServeMux) {
Expand Down
9 changes: 9 additions & 0 deletions internal/controllers/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package controllers

import "net/http"

func NotFound(w http.ResponseWriter, r *http.Request) {

Check failure on line 5 in internal/controllers/common.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
code := http.StatusNotFound
w.WriteHeader(code)
w.Write(responseErrorBytes(code))
}

0 comments on commit 85aab00

Please sign in to comment.