12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package routers
- import (
- "eta/eta_mini_ht_api/controllers"
- "eta/eta_mini_ht_api/controllers/media"
- "eta/eta_mini_ht_api/controllers/order"
- "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.SubscribeController{},
- ),
- ),
- 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.NSNamespace("/product",
- web.NSInclude(
- &product.ProductController{},
- ),
- ),
- web.NSNamespace("/order",
- web.NSInclude(
- &order.OrderController{},
- ),
- ),
- web.NSNamespace("/ws",
- web.NSInclude(
- &controllers.WebSocketController{},
- ),
- ),
- web.NSNamespace("/system",
- web.NSInclude(
- &sys.SysController{},
- ),
- ),
- )
- web.AddNamespace(ns)
- }
|