package routers import ( "eta/eta_mini_ht_api/controllers" "eta/eta_mini_ht_api/controllers/chart" "eta/eta_mini_ht_api/controllers/home" "eta/eta_mini_ht_api/controllers/media" "eta/eta_mini_ht_api/controllers/order" "eta/eta_mini_ht_api/controllers/payment" "eta/eta_mini_ht_api/controllers/product" "eta/eta_mini_ht_api/controllers/report" "eta/eta_mini_ht_api/controllers/sys" "eta/eta_mini_ht_api/controllers/user" "eta/eta_mini_ht_api/controllers/web_hook" "eta/eta_mini_ht_api/middleware" "github.com/beego/beego/v2/server/web" "github.com/beego/beego/v2/server/web/filter/cors" "time" ) func init() { web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{ AllowAllOrigins: true, // 允许所有来源的请求 AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, MaxAge: 12 * time.Hour, })) //增加授权拦截 web.InsertFilter("*", web.BeforeRouter, middleware.AuthMiddleware()) web.InsertFilter("/htapi/webhook/*", web.BeforeRouter, middleware.WebHookAuthMiddleware()) ns := web.NewNamespace("/htapi", web.NSNamespace("/user", web.NSInclude( &user.UserController{}, &user.BookMarkController{}, ), ), web.NSNamespace("/home", web.NSInclude( &home.HomeController{}, ), ), web.NSNamespace("/auth", web.NSInclude( &user.AuthController{}, ), ), web.NSNamespace("/account", web.NSInclude( &user.AccountController{}, ), ), web.NSNamespace("/report", web.NSInclude( &report.ReportController{}, ), ), web.NSNamespace("/media", web.NSInclude( &media.MediaController{}, ), ), web.NSNamespace("/analyst", web.NSInclude( &user.AnalystController{}, ), ), web.NSNamespace("/webhook ", web.NSInclude( &web_hook.HTFuturesAccountController{}, &web_hook.HTFuturesTradeController{}, &web_hook.ESController{}, ), ), web.NSNamespace("/product", web.NSInclude( &product.ProductController{}, ), ), web.NSNamespace("/order", web.NSInclude( &order.OrderController{}, &order.SubscribeController{}, ), ), web.NSNamespace("/ws", web.NSInclude( &controllers.WebSocketController{}, ), ), web.NSNamespace("/system", web.NSInclude( &sys.SysController{}, ), ), web.NSNamespace("/payment", web.NSInclude( &payment.PaymentController{}, ), ), web.NSNamespace("/chart", web.NSInclude( &chart.ChartController{}, ), ), ) web.AddNamespace(ns) }