mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
working on not found handler
This commit is contained in:
16
controller/404.go
Normal file
16
controller/404.go
Normal file
@@ -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")
|
||||
}
|
||||
1
public/404.html
Normal file
1
public/404.html
Normal file
@@ -0,0 +1 @@
|
||||
404: Page not found
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user