summaryrefslogtreecommitdiff
path: root/pkg/backend/routes.go
blob: 960a2e84c2707bf33b758fa45779073ec7e6e6a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package backend

import (
	"net/http"

	"git.adyxax.org/adyxax/tfstated/pkg/database"
	"git.adyxax.org/adyxax/tfstated/pkg/middlewares/basic_auth"
)

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)))
}