feat: add vm read endpoints
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user