router.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_mini_bridge/controllers"
  11. "github.com/beego/beego/v2/server/web"
  12. "github.com/beego/beego/v2/server/web/filter/cors"
  13. )
  14. func init() {
  15. web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{
  16. AllowAllOrigins: true,
  17. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  18. AllowHeaders: []string{"Origin", "Authorization", "Uuid", "Accesstoken", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  19. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
  20. AllowCredentials: true,
  21. }))
  22. ns := web.NewNamespace("/v1",
  23. web.NSNamespace("/report",
  24. web.NSInclude(
  25. &controllers.ReportController{},
  26. ),
  27. ),
  28. web.NSNamespace("/chart_permission",
  29. web.NSInclude(
  30. &controllers.ChartPermissionController{},
  31. ),
  32. ),
  33. web.NSNamespace("/chart",
  34. web.NSInclude(
  35. &controllers.ChartController{},
  36. ),
  37. ),
  38. web.NSNamespace("/wechat",
  39. web.NSInclude(
  40. &controllers.WeChatController{},
  41. ),
  42. ),
  43. web.NSNamespace("/classify",
  44. web.NSInclude(
  45. &controllers.ClassifyController{},
  46. ),
  47. ),
  48. )
  49. nsNoAuth := web.NewNamespace("/v1/noAuth",
  50. web.NSNamespace("/report",
  51. web.NSInclude(
  52. &controllers.ReportNoAuthController{},
  53. ),
  54. ),
  55. )
  56. web.AddNamespace(ns, nsNoAuth)
  57. }