You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
766 B

package main
import (
"k8s-manager/handler/config"
"k8s-manager/handler/node"
"k8s-manager/handler/sys"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func main() {
// 初始化默认的路由引擎
r := gin.Default()
// 中间件 middle ware
corsDC := cors.DefaultConfig()
// 配置响应头,通过属性配置
corsDC.AllowAllOrigins = true // 允许全部的源,访问
corsDC.AllowCredentials = true
corsDC.AddAllowHeaders("Authorization")
// 应用到全部路上
r.Use(cors.New(corsDC))
// 定义路由
r.GET("/ping", sys.Ping)
r.GET("/node/get", node.List)
r.POST("/config/upload", config.Upload)
r.GET("/config", config.Config)
r.Static("/ui", "./ui")
r.Run(":8080") // 监听并在 0.0.0.0:8080 上启动服务
}