router.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package routers
  2. import (
  3. "eta/eta_mini_api/controllers"
  4. beego "github.com/beego/beego/v2/server/web"
  5. "github.com/beego/beego/v2/server/web/filter/cors"
  6. )
  7. func init() {
  8. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  9. AllowAllOrigins: true,
  10. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  11. AllowHeaders: []string{"Origin", "Authorization", "Uuid", "Accesstoken", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  12. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  13. AllowCredentials: true,
  14. }))
  15. // beego.Router("/", &controllers.MainController{})
  16. ns := beego.NewNamespace("/api",
  17. beego.NSNamespace("/user",
  18. beego.NSInclude(
  19. &controllers.UserController{},
  20. &controllers.UserAuthController{},
  21. ),
  22. ),
  23. beego.NSNamespace("/wechat",
  24. beego.NSInclude(
  25. &controllers.WechatController{},
  26. ),
  27. ),
  28. beego.NSNamespace("/report",
  29. beego.NSInclude(
  30. &controllers.ReportController{},
  31. ),
  32. ),
  33. beego.NSNamespace("/chart",
  34. beego.NSInclude(
  35. &controllers.ChartController{},
  36. ),
  37. ),
  38. beego.NSNamespace("/mychart",
  39. beego.NSInclude(
  40. &controllers.MyChartController{},
  41. ),
  42. ),
  43. beego.NSNamespace("/myreport",
  44. beego.NSInclude(
  45. &controllers.MyReportController{},
  46. ),
  47. ),
  48. beego.NSNamespace("/chart_perimission",
  49. beego.NSInclude(
  50. &controllers.ChartPermissionController{},
  51. ),
  52. ),
  53. beego.NSNamespace("/system",
  54. beego.NSInclude(
  55. &controllers.MiniConfigController{},
  56. ),
  57. ),
  58. beego.NSNamespace("/banner",
  59. beego.NSInclude(
  60. &controllers.BannerController{},
  61. ),
  62. ),
  63. )
  64. h5ns := beego.NewNamespace("/api/h5",
  65. beego.NSNamespace("/report",
  66. beego.NSInclude(
  67. &controllers.ReportNoAuthController{},
  68. ),
  69. ),
  70. beego.NSNamespace("/chart_perimission",
  71. beego.NSInclude(
  72. &controllers.ChartPermissionNoAuthController{},
  73. ),
  74. ),
  75. )
  76. beego.AddNamespace(ns, h5ns)
  77. }