summaryrefslogtreecommitdiffstats
path: root/api/handlers/html.go
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2025-09-09 22:44:09 +0100
committerLeonardo Bishop <me@leonardobishop.net>2025-09-09 22:44:09 +0100
commitf1741a7faa9538e9b12ac60e0fbf6c7721a36059 (patch)
tree2b70b14fc20a8520718910a0cd2e0134790c6f53 /api/handlers/html.go
Initial commit
Diffstat (limited to 'api/handlers/html.go')
-rw-r--r--api/handlers/html.go27
1 files changed, 27 insertions, 0 deletions
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))
+ }
+}