routes.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * @description: 路由配置
  3. * @Author: CP
  4. * @Date: 2020-08-23 21:32:54
  5. * @FilePath: \construction_management\web\routes\routes.go
  6. */
  7. package routes
  8. import (
  9. "github.com/kataras/iris/v12/mvc"
  10. "go.mod/bootstrap"
  11. "go.mod/services"
  12. "go.mod/web/controllers"
  13. "go.mod/web/middleware"
  14. )
  15. func Configure(b *bootstrap.Bootstrapper) {
  16. //service加载
  17. ProjectAccountService := services.NewProjectAccountService()
  18. LoginService := services.NewLoginService()
  19. ProjectService := services.NewProjectService()
  20. //CSRF相关
  21. b.Use(middleware.SetCsrf)
  22. //b.Party("/", protect)
  23. //protect := NewCsrf()
  24. //登录相关
  25. //login := mvc.New(b.Party("/", protect))
  26. login := mvc.New(b.Party("/"))
  27. login.Register(ProjectAccountService)
  28. login.Register(LoginService)
  29. login.Handle(new(controllers.LoginController))
  30. // todolist相关
  31. todo := mvc.New(b.Party("/todolist"))
  32. todo.Router.Use(middleware.SessionsAuth)
  33. todo.Handle(new(controllers.TodoController))
  34. //标段相关
  35. bidsection := mvc.New(b.Party("/bidsection"))
  36. bidsection.Register(ProjectService)
  37. bidsection.Router.Use(middleware.SessionsAuth)
  38. bidsection.Handle(new(controllers.BidsectionController))
  39. //用户相关
  40. account := mvc.New(b.Party("/account"))
  41. account.Register(ProjectAccountService)
  42. account.Router.Use(middleware.SessionsAuth)
  43. account.Handle(new(controllers.AccountController))
  44. // 项目相关
  45. project := mvc.New(b.Party("/project"))
  46. project.Router.Use(middleware.SessionsAuth)
  47. project.Handle(new(controllers.ProjectController))
  48. }