package app import ( "bigdata_archives/app/controller" middlewares "bigdata_archives/app/middleware" "bigdata_archives/app/routers" "bigdata_archives/configs" "github.com/gin-gonic/gin" ) func InitRouter() error { engine := gin.New() gin.SetMode(configs.Config.GetString("server.mode")) engine.Use(middlewares.Cors()) //配置前端静态资源 engine.StaticFile("/", "./frontend/dist/index.html") engine.Static("/assets", "./frontend/dist/assets") engine.Static("/libs", "./frontend/dist/libs") engine.StaticFile("/favicon.ico", "./frontend/dist/favicon.ico") //图片静态资源访问 engine.Static("/image", "./image") engine.GET("/ws/temperature-humidity", controller.WebSocketHandler) routers.UserRouter(engine) routers.MonitorRouter(engine) engine.Use(middlewares.AdminMiddleware()) routers.SystemRouter(engine) routers.TemperatureRouter(engine) return engine.Run(configs.Config.GetString("server.port")) }