summaryrefslogtreecommitdiff
path: root/pkg/webui/routes.go
blob: 6ebe90bdbfaf43178bff4d7e7edbdaa022f4276e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 /logout", session(requireLogin(handleLogoutGET(db))))
	mux.Handle("GET /static/", cache(http.FileServer(http.FS(staticFS))))
	mux.Handle("GET /", session(requireLogin(handleIndexGET())))
}