From f1741a7faa9538e9b12ac60e0fbf6c7721a36059 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Tue, 9 Sep 2025 22:44:09 +0100 Subject: Initial commit --- api/handlers/html.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 api/handlers/html.go (limited to 'api/handlers/html.go') diff --git a/api/handlers/html.go b/api/handlers/html.go new file mode 100644 index 0000000..dd5d4e8 --- /dev/null +++ b/api/handlers/html.go @@ -0,0 +1,27 @@ +package handlers + +import ( + "net/http" + + "git.leonardobishop.net/history/pkg/entries" + "git.leonardobishop.net/history/pkg/html" +) + +func GetEntriesHtml(entriesService entries.Service, htmlService html.Service) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + entries, err := entriesService.GetEntries() + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + html, err := htmlService.GenerateHtml(entries) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + w.Header().Set("Content-Type", "text/html;charset=UTF-8") + w.Write([]byte(html)) + } +} -- cgit v1.2.3-70-g09d2