feat: add vm read endpoints

This commit is contained in:
Philipp
2026-06-11 11:10:12 +02:00
parent bf31a8db37
commit 262ec4f91b
7 changed files with 452 additions and 0 deletions
+10
View File
@@ -25,6 +25,7 @@ import (
"proxui/backend/internal/operator"
"proxui/backend/internal/profile"
"proxui/backend/internal/rbac"
"proxui/backend/internal/vm"
)
func main() {
@@ -66,6 +67,7 @@ func main() {
clusterRepository := cluster.NewRepository(db, tokenCipher)
clusterAdminHandler := clusteradmin.NewHandler(clusterRepository)
operatorMiddleware := operator.NewMiddleware(cfg.OperatorToken)
vmHandler := vm.NewHandler(vm.NewSQLRepository(db))
mux := http.NewServeMux()
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
@@ -94,6 +96,14 @@ func main() {
),
),
)
mux.Handle(
"GET /projects/{projectID}/vms",
authMiddleware.RequireAuth(profileMiddleware.EnsureProfile(http.HandlerFunc(vmHandler.ListProjectVMs))),
)
mux.Handle(
"GET /vms/{vmID}",
authMiddleware.RequireAuth(profileMiddleware.EnsureProfile(http.HandlerFunc(vmHandler.GetVM))),
)
clusterManageChain := func(handler http.HandlerFunc) http.Handler {
return operatorMiddleware.RequireOperator(authorizationMiddleware.Require(rbac.ActionClusterManage, handler))
}