router.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // @APIVersion 1.0.0
  2. // @Title beego Test API
  3. // @Description beego has a very cool tools to autogenerate documents for your API
  4. // @Contact astaxie@gmail.com
  5. // @TermsOfServiceUrl http://beego.me/
  6. // @License Apache 2.0
  7. // @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
  8. package routers
  9. import (
  10. "eta/eta_hub/controllers"
  11. "github.com/beego/beego/v2/server/web"
  12. "github.com/beego/beego/v2/server/web/filter/cors"
  13. )
  14. func init() {
  15. //解决跨域问题
  16. web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{
  17. AllowAllOrigins: true,
  18. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  19. AllowHeaders: []string{"Origin", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "nonce", "timestamp", "appid", "signature"},
  20. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  21. AllowCredentials: true,
  22. }))
  23. var ns = web.NewNamespace("/v1",
  24. web.NSNamespace("/report",
  25. web.NSInclude(
  26. &controllers.ReportController{},
  27. ),
  28. ),
  29. web.NSNamespace("/english_report",
  30. web.NSInclude(
  31. &controllers.EnglishReportController{},
  32. ),
  33. ),
  34. web.NSNamespace("/smart_report",
  35. web.NSInclude(
  36. &controllers.SmartReportController{},
  37. ),
  38. ),
  39. web.NSNamespace("/edb",
  40. web.NSInclude(
  41. &controllers.EdbController{},
  42. ),
  43. ),
  44. web.NSNamespace("/chart",
  45. web.NSInclude(
  46. &controllers.ChartController{},
  47. ),
  48. ),
  49. web.NSNamespace("/statistic_analysis",
  50. web.NSInclude(
  51. &controllers.StatisticAnalysisController{},
  52. ),
  53. ),
  54. web.NSNamespace("/supply_analysis",
  55. web.NSInclude(
  56. &controllers.SupplyAnalysisController{},
  57. ),
  58. ),
  59. web.NSNamespace("/datamanage",
  60. web.NSInclude(
  61. &controllers.EdbInfoController{},
  62. ),
  63. ),
  64. web.NSNamespace("/entry",
  65. web.NSInclude(
  66. &controllers.TradeCommonController{},
  67. ),
  68. ),
  69. web.NSNamespace("/admin",
  70. web.NSInclude(
  71. &controllers.SysAdminController{},
  72. ),
  73. ),
  74. web.NSNamespace("/document_manage",
  75. web.NSInclude(
  76. &controllers.OutsideReportController{},
  77. ),
  78. ),
  79. web.NSNamespace("/resource_deal_with",
  80. web.NSInclude(
  81. &controllers.ResourceDealWithController{},
  82. ),
  83. ),
  84. web.NSNamespace("/sandbox",
  85. web.NSInclude(
  86. &controllers.SandboxController{},
  87. ),
  88. ),
  89. )
  90. web.AddNamespace(ns)
  91. }