diff --git a/controller/404.go b/controller/404.go new file mode 100644 index 0000000..702b912 --- /dev/null +++ b/controller/404.go @@ -0,0 +1,16 @@ +package controller + +import ( + //"encoding/json" + "fmt" + "github.com/julienschmidt/httprouter" + "net/http" +) + +// IndexGET displays the home page +func NotFound404(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + + http.Redirect(w, r, "/404.html", 404) + + fmt.Fprint(w, "test") +} diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..bca257a --- /dev/null +++ b/public/404.html @@ -0,0 +1 @@ +404: Page not found \ No newline at end of file diff --git a/route/route.go b/route/route.go index cad3613..3961d06 100644 --- a/route/route.go +++ b/route/route.go @@ -18,5 +18,7 @@ func Routes() *httprouter.Router { //set up public folder path r.ServeFiles("/public/*filepath", http.Dir("./public")) + //404 not found + r.NotFound = http.NotFoundHandler() return r }