This commit is contained in:
Ybehrooz
2025-08-03 14:54:21 +03:30
parent 97d1424fa7
commit b1656a5e65
3 changed files with 319 additions and 6 deletions

26
main.go
View File

@@ -126,6 +126,7 @@ func main() {
router.HandleFunc("/register", registerHnadler)
router.HandleFunc("/login", loginHandler)
router.HandleFunc("/createcluster", handler.CreateClusterHandler)
router.HandleFunc("/deletecluster", handler.Deletecluster)
router.HandleFunc("/clusters", handler.ListUserClusters)
router.HandleFunc("/connect", handler.Connect)
// router.HandleFunc("/cluster_nodes", handler.Cluster_nodes)
@@ -142,16 +143,33 @@ func main() {
router.HandleFunc("/pod_logs", handler.Pod_logs)
router.HandleFunc("/pod_exec", handler.Pod_exec)
router.HandleFunc("/pod_delete", handler.Pod_delete)
router.HandleFunc("/service_delete", handler.Service_delete)
router.HandleFunc("/deployment_delete", handler.Deployment_delete)
router.HandleFunc("/statefulSet_delete", handler.StatefulSet_delete)
router.HandleFunc("/daemonsets_delete", handler.Daemonsets_delete)
router.HandleFunc("/jobsName_delete", handler.JobsName_delete)
router.HandleFunc("/replicaset_delete", handler.Replicaset_delete)
router.HandleFunc("/replicationcontroller_delete", handler.Replicationcontroller_delete)
router.HandleFunc("/cronjob_delete", handler.Cronjob_delete)
//handler.RegsiterClusterRoute(router)
// Enable CORS
// c := cors.New(cors.Options{
// AllowedOrigins: []string{"*"}, // Allow all origins
// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
// AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"},
// ExposedHeaders: []string{"Content-Length"},
// AllowCredentials: true,
// Debug: true, // Enable debug logging
// })
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"}, // Allow all origins
AllowedOrigins: []string{"*", "http://localhost:4200"}, // frontend origin
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"},
ExposedHeaders: []string{"Content-Length"},
AllowCredentials: true,
Debug: true, // Enable debug logging
AllowCredentials: false,
Debug: true,
})
http.ListenAndServe("0.0.0.0:8082", c.Handler(router))