flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit d105e77524d5c2cb84c198b364de43d0e83cb8f1
parent 4b85797053e9433b25d6961b53092975a66c6a45
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 24 Oct 2020 11:35:43 -0700

cleanup errors

Diffstat:
Mhttp.go | 6++++--
Mtemplates/error.html | 5++++-
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/http.go b/http.go @@ -20,7 +20,10 @@ var t *template.Template const InternalServerErrorMsg = "500: Internal Server Error" func renderError(w http.ResponseWriter, errorMsg string, statusCode int) { - data := struct{ ErrorMsg string }{errorMsg} + data := struct { + PageTitle string + ErrorMsg string + }{"Error!", errorMsg} err := t.ExecuteTemplate(w, "error.html", data) if err != nil { // shouldn't happen probably http.Error(w, errorMsg, statusCode) @@ -58,7 +61,6 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { renderError(w, InternalServerErrorMsg, 500) return } - } func editFileHandler(w http.ResponseWriter, r *http.Request) { diff --git a/templates/error.html b/templates/error.html @@ -1 +1,4 @@ -{{ .ErrorMsg }} +{{template "header" .}} +<h1>Error</h1> +<div class="error">{{ .ErrorMsg }}</div> +{{template "footer" .}}