router.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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", "Authorization", "Uuid", "Accesstoken", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  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. )
  70. web.AddNamespace(ns)
  71. }