From 36e3d473f2126e920061218996cfa5cfecade7d6 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 30 Dec 2024 23:07:00 +0100 Subject: chore(tfstated): refactor backend code to a dedicated package --- pkg/backend/routes.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pkg/backend/routes.go (limited to 'pkg/backend/routes.go') 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))) +} -- cgit v1.2.3