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

import (
	"net/http"

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

func addRoutes(
	mux *http.ServeMux,
	db *database.DB,
) {
	session := sessionsMiddleware(db)
	requireLogin := loginMiddleware(db)
	mux.Handle("GET /healthz", handleHealthz())
	mux.Handle("GET /login", session(handleLoginGET()))
	mux.Handle("POST /login", session(handleLoginPOST(db)))
	mux.Handle("GET /static/", cache(http.FileServer(http.FS(staticFS))))
	mux.Handle("GET /", session(requireLogin(handleIndexGET())))
}