router.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. "github.com/astaxie/beego"
  11. "github.com/astaxie/beego/plugins/cors"
  12. "hongze/hongze_admin/controllers"
  13. )
  14. func init() {
  15. //解决跨域问题
  16. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  17. AllowAllOrigins: true,
  18. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  19. AllowHeaders: []string{"Origin", "Authorization", "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. ns := beego.NewNamespace("/admin",
  24. beego.NSNamespace("/sysuser",
  25. beego.NSInclude(
  26. &controllers.SysUserController{},
  27. ),
  28. beego.NSInclude(
  29. &controllers.SysUserAuthController{},
  30. ),
  31. ),
  32. beego.NSNamespace("/classify",
  33. beego.NSInclude(
  34. &controllers.ClassifyController{},
  35. ),
  36. ),
  37. beego.NSNamespace("/banner",
  38. beego.NSInclude(
  39. &controllers.BannerController{},
  40. ),
  41. ),
  42. beego.NSNamespace("/report",
  43. beego.NSInclude(
  44. &controllers.ReportController{},
  45. ),
  46. ),
  47. beego.NSNamespace("/voice",
  48. beego.NSInclude(
  49. &controllers.VoiceController{},
  50. ),
  51. ),
  52. beego.NSNamespace("/ppt",
  53. beego.NSInclude(
  54. &controllers.PptController{},
  55. ),
  56. ),
  57. beego.NSNamespace("/entry",
  58. beego.NSInclude(
  59. &controllers.TargetController{},
  60. ),
  61. ),
  62. )
  63. beego.AddNamespace(ns)
  64. }