diff options
author | Alan Pearce | 2024-06-21 13:02:08 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-21 15:44:12 +0200 |
commit | a1dfc548198a1326e71f1dd70303a5d3441f7a39 (patch) | |
tree | 03e7d60dc389678ee7cadaac4d5e64596dffde91 /internal/server/error.go | |
parent | cac323d9ae70f55a43fd99b73e60cf614be11797 (diff) | |
download | searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.lz searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.zst searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.zip |
refactor: switch to templ for HTML templates
Diffstat (limited to 'internal/server/error.go')
-rw-r--r-- | internal/server/error.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/internal/server/error.go b/internal/server/error.go index e700d3b..4a8acbc 100644 --- a/internal/server/error.go +++ b/internal/server/error.go @@ -3,6 +3,8 @@ package server import ( "log/slog" "net/http" + + "searchix/internal/components" "searchix/internal/config" ) @@ -14,9 +16,9 @@ func createErrorHandler( if message == "" { message = http.StatusText(code) } - indexData := TemplateData{ + indexData := components.TemplateData{ ExtraHeadHTML: config.Web.ExtraHeadHTML, - Sources: config.Importer.Sources, + Sources: sources, Code: code, Message: message, } @@ -24,9 +26,9 @@ func createErrorHandler( w.Header().Del("Vary") w.WriteHeader(code) if r.Header.Get("Fetch") == "true" { - err = templates["error"].ExecuteTemplate(w, "main", indexData) + err = components.Error(indexData).Render(r.Context(), w) } else { - err = templates["error"].Execute(w, indexData) + err = components.ErrorPage(indexData).Render(r.Context(), w) } if err != nil { slog.Error( |