forked from alibaba/kt-connect
-
Notifications
You must be signed in to change notification settings - Fork 2
/
router.go
43 lines (36 loc) · 2.28 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package server
import (
"github.com/alibaba/kt-connect/pkg/apiserver/common"
"github.com/alibaba/kt-connect/pkg/apiserver/controllers"
"github.com/gin-gonic/gin"
)
// NewRouter api router
func NewRouter(context common.Context) *gin.Engine {
router := gin.New()
router.Use(gin.Logger())
router.Use(gin.Recovery())
ktController := controllers.KTController{Context: context}
clusterController := controllers.ClusterController{Context: context}
terminalController := controllers.TerminalController{Context: context}
istioController := controllers.IstioController{Context: context}
router.GET("/api/components", ktController.Components)
router.GET("/api/cluster/namespaces", clusterController.Namespaces)
router.GET("/api/cluster/namespaces/:namespace/components", ktController.ComponentsInNamespace)
router.GET("/api/cluster/namespaces/:namespace/services", clusterController.Services)
router.GET("/api/cluster/namespaces/:namespace/services/:name", clusterController.Service)
router.GET("/api/cluster/namespaces/:namespace/endpoints", clusterController.Endpoints)
router.GET("/api/cluster/namespaces/:namespace/endpoints/:name", clusterController.Endpoint)
router.GET("/api/cluster/namespaces/:namespace/replicasets/:name", clusterController.ReplicaSet)
router.GET("/api/cluster/namespaces/:namespace/deployments", clusterController.Deployments)
router.GET("/api/cluster/namespaces/:namespace/deployments/:name", clusterController.Deployment)
router.GET("/api/cluster/namespaces/:namespace/pods", clusterController.Pods)
router.GET("/api/cluster/namespaces/:namespace/pods/:name", clusterController.Pod)
router.GET("/api/cluster/namespaces/:namespace/pods/:name/log", clusterController.PodLog)
router.GET("/api/cluster/namespaces/:namespace/virtualservices", istioController.VirtualServices)
router.GET("/api/cluster/namespaces/:namespace/virtualservices/:name", istioController.VirtualService)
router.GET("/api/cluster/namespaces/:namespace/destinationrules", istioController.DestinationRules)
router.GET("/api/cluster/namespaces/:namespace/destinationrules/:name", istioController.DestinationRule)
router.PUT("/api/cluster/namespaces/:namespace/destinationrules/:name/:version", istioController.AddVersionToDestinationRule)
router.GET("/ws/terminal", terminalController.Terminal)
return router
}