summaryrefslogtreecommitdiffstats
path: root/api/router.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/router.go
Initial commit
Diffstat (limited to 'api/router.go')
-rw-r--r--api/router.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/api/router.go b/api/router.go
new file mode 100644
index 0000000..9ea7ac0
--- /dev/null
+++ b/api/router.go
@@ -0,0 +1,27 @@
+package api
+
+import (
+ "net/http"
+
+ "git.leonardobishop.net/history/api/handlers"
+ "git.leonardobishop.net/history/api/middleware"
+ "git.leonardobishop.net/history/internal/config"
+ "git.leonardobishop.net/history/pkg/entries"
+ "git.leonardobishop.net/history/pkg/html"
+)
+
+type ApiServices struct {
+ EntiresService entries.Service
+ HtmlService html.Service
+
+ Config config.Config
+}
+
+func NewServer(api ApiServices) *http.ServeMux {
+ mux := http.NewServeMux()
+
+ mux.HandleFunc("POST /record", middleware.Cors(handlers.RecordEntry(api.EntiresService, api.Config.Token)))
+ mux.HandleFunc("GET /html", handlers.GetEntriesHtml(api.EntiresService, api.HtmlService))
+
+ return mux
+}