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_perimission", beego.NSInclude( &controllers.ChartPermissionController{}, ), ), ) beego.AddNamespace(ns) }