diff options
Diffstat (limited to '')
-rw-r--r-- | pkg/webui/error.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/webui/error.go b/pkg/webui/error.go new file mode 100644 index 0000000..afce9a6 --- /dev/null +++ b/pkg/webui/error.go @@ -0,0 +1,23 @@ +package webui + +import ( + "html/template" + "net/http" +) + +var errorTemplates = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/error.html")) + +func errorResponse(w http.ResponseWriter, status int, err error) { + type ErrorData struct { + Page + Err error + Status int + StatusText string + } + render(w, errorTemplates, status, &ErrorData{ + Page: Page{Title: "Error", Section: "error"}, + Err: err, + Status: status, + StatusText: http.StatusText(status), + }) +} |