From f1aef623b6b06e2b0e92b99acacc70d758f81b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=CC=81scar=20M=2E=20Lage?= Date: Mon, 28 Mar 2022 21:09:07 +0200 Subject: [PATCH] Fix: Show proper 404 if version doesn't exist. Fix #1 --- server/app.go | 1 + server/server.go | 1 + views/404.html | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 views/404.html diff --git a/server/app.go b/server/app.go index 17634a5..d2bcde1 100644 --- a/server/app.go +++ b/server/app.go @@ -29,6 +29,7 @@ func WikiPage(c echo.Context) error { // If record not found, show 404 if err.Error() == "record not found" { return c.Render(http.StatusOK, "notfound.html", map[string]interface{}{ + return c.Render(http.StatusNotFound, "404.html", map[string]interface{}{ "name": page_id, }) } diff --git a/server/server.go b/server/server.go index 888ab4c..760962c 100644 --- a/server/server.go +++ b/server/server.go @@ -57,6 +57,7 @@ func Serve() { templates["edit.html"] = template.Must(template.ParseFiles("views/edit.html", "views/base.html")) templates["about.html"] = template.Must(template.ParseFiles("views/about.html", "views/base.html")) templates["notfound.html"] = template.Must(template.ParseFiles("views/notfound.html", "views/base.html")) + templates["404.html"] = template.Must(template.ParseFiles("views/404.html", "views/base.html")) e.Renderer = &TemplateRegistry{ templates: templates, } diff --git a/views/404.html b/views/404.html new file mode 100644 index 0000000..37c192f --- /dev/null +++ b/views/404.html @@ -0,0 +1,8 @@ +{{define "title"}} + Wikingo | {{index . "name"}} +{{end}} + +{{define "body"}} +

404

+

Page not found

+{{end}}