package routers import ( "eta/eta_mini_api/controllers" beego "github.com/beego/beego/v2/server/web" "github.com/beego/beego/v2/server/web/filter/cors" ) func init() { beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ AllowAllOrigins: true, AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowHeaders: []string{"Origin", "Authorization", "Uuid", "Accesstoken", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"}, ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"}, AllowCredentials: true, })) // beego.Router("/", &controllers.MainController{}) ns := beego.NewNamespace("/api", beego.NSNamespace("/user", beego.NSInclude( &controllers.UserController{}, &controllers.UserAuthController{}, ), ), beego.NSNamespace("/wechat", beego.NSInclude( &controllers.WechatController{}, ), ), beego.NSNamespace("/report", beego.NSInclude( &controllers.ReportController{}, ), ), beego.NSNamespace("/chart", beego.NSInclude( &controllers.ChartController{}, ), ), beego.NSNamespace("/mychart", beego.NSInclude( &controllers.MyChartController{}, ), ), beego.NSNamespace("/myreport", beego.NSInclude( &controllers.MyReportController{}, ), ), beego.NSNamespace("/chart_perimission", beego.NSInclude( &controllers.ChartPermissionController{}, ), ), beego.NSNamespace("/system", beego.NSInclude( &controllers.MiniConfigController{}, ), ), beego.NSNamespace("/banner", beego.NSInclude( &controllers.BannerController{}, ), ), ) h5ns := beego.NewNamespace("/api/h5", beego.NSNamespace("/report", beego.NSInclude( &controllers.ReportNoAuthController{}, ), ), beego.NSNamespace("/chart_perimission", beego.NSInclude( &controllers.ChartPermissionNoAuthController{}, ), ), ) beego.AddNamespace(ns, h5ns) }