Added error 404 handler.
This commit is contained in:
parent
9dba81b336
commit
aec332f746
@ -51,6 +51,8 @@ func main() {
|
|||||||
hand := http.NewHandlers(*captchaExpiry, *databasesPath, *guestbookOwner, *guestbookPageSize)
|
hand := http.NewHandlers(*captchaExpiry, *databasesPath, *guestbookOwner, *guestbookPageSize)
|
||||||
srv := http.NewHttpServer()
|
srv := http.NewHttpServer()
|
||||||
|
|
||||||
|
srv.SetNotFoundHandler(hand.NotFound)
|
||||||
|
|
||||||
srv.ServeStatic("/assets/*filepath", hand.AssetsFS())
|
srv.ServeStatic("/assets/*filepath", hand.AssetsFS())
|
||||||
srv.GET("/", hand.Index)
|
srv.GET("/", hand.Index)
|
||||||
srv.GET("/stuff", hand.Stuff)
|
srv.GET("/stuff", hand.Stuff)
|
||||||
|
@ -81,3 +81,7 @@ func (h *Handlers) Robots(w http.ResponseWriter, r *http.Request) {
|
|||||||
data, _ := web.AssetsGetFile("robots.txt")
|
data, _ := web.AssetsGetFile("robots.txt")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handlers) NotFound(w http.ResponseWriter, r *http.Request) {
|
||||||
|
web.NotFound("Not Found", w)
|
||||||
|
}
|
||||||
|
@ -17,6 +17,8 @@ import (
|
|||||||
|
|
||||||
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer article.pug
|
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer article.pug
|
||||||
|
|
||||||
|
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer error404.pug
|
||||||
|
|
||||||
//go:embed assets
|
//go:embed assets
|
||||||
var assetsDir embed.FS
|
var assetsDir embed.FS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user