summaryrefslogtreecommitdiff
path: root/pkg/backend/routes.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-12-30 23:07:00 +0100
committerJulien Dessaux2024-12-30 23:07:00 +0100
commit36e3d473f2126e920061218996cfa5cfecade7d6 (patch)
treec77078316db50cd5da7e68ddb3a8cb830ba5c612 /pkg/backend/routes.go
parentchore(tfstated): refactor setting last login date time on successful HTTP bas... (diff)
downloadtfstated-36e3d473f2126e920061218996cfa5cfecade7d6.tar.gz
tfstated-36e3d473f2126e920061218996cfa5cfecade7d6.tar.bz2
tfstated-36e3d473f2126e920061218996cfa5cfecade7d6.zip
chore(tfstated): refactor backend code to a dedicated package
Diffstat (limited to 'pkg/backend/routes.go')
-rw-r--r--pkg/backend/routes.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/backend/routes.go b/pkg/backend/routes.go
new file mode 100644
index 0000000..058febd
--- /dev/null
+++ b/pkg/backend/routes.go
@@ -0,0 +1,22 @@
+package backend
+
+import (
+ "net/http"
+
+ "git.adyxax.org/adyxax/tfstated/pkg/basic_auth"
+ "git.adyxax.org/adyxax/tfstated/pkg/database"
+)
+
+func addRoutes(
+ mux *http.ServeMux,
+ db *database.DB,
+) {
+ mux.Handle("GET /healthz", handleHealthz())
+
+ basicAuth := basic_auth.Middleware(db)
+ mux.Handle("DELETE /", basicAuth(handleDelete(db)))
+ mux.Handle("GET /", basicAuth(handleGet(db)))
+ mux.Handle("LOCK /", basicAuth(handleLock(db)))
+ mux.Handle("POST /", basicAuth(handlePost(db)))
+ mux.Handle("UNLOCK /", basicAuth(handleUnlock(db)))
+}