1
0

Added error 404 handler.

This commit is contained in:
Alexander Andreev 2023-02-05 05:25:20 +04:00
parent 9dba81b336
commit aec332f746
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
3 changed files with 8 additions and 0 deletions

View File

@ -51,6 +51,8 @@ func main() {
hand := http.NewHandlers(*captchaExpiry, *databasesPath, *guestbookOwner, *guestbookPageSize)
srv := http.NewHttpServer()
srv.SetNotFoundHandler(hand.NotFound)
srv.ServeStatic("/assets/*filepath", hand.AssetsFS())
srv.GET("/", hand.Index)
srv.GET("/stuff", hand.Stuff)

View File

@ -81,3 +81,7 @@ func (h *Handlers) Robots(w http.ResponseWriter, r *http.Request) {
data, _ := web.AssetsGetFile("robots.txt")
w.Write(data)
}
func (h *Handlers) NotFound(w http.ResponseWriter, r *http.Request) {
web.NotFound("Not Found", w)
}

View File

@ -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 error404.pug
//go:embed assets
var assetsDir embed.FS