router.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from fastapi import APIRouter
  2. from app.api.endpoints import (
  3. account,
  4. agent,
  5. auth,
  6. common,
  7. config,
  8. node_configuration,
  9. email,
  10. notification,
  11. order,
  12. payment,
  13. plugin,
  14. product,
  15. provider,
  16. proxy,
  17. slot,
  18. sms,
  19. task,
  20. ticket,
  21. user,
  22. vas_task,
  23. webhook,
  24. )
  25. # 公共路由
  26. public_router = APIRouter()
  27. # 受保护路由
  28. protected_router = APIRouter()
  29. # 管理员级别路由
  30. admin_required_router = APIRouter()
  31. # 模块列表
  32. _modules = [
  33. account,
  34. agent,
  35. auth,
  36. common,
  37. config,
  38. node_configuration,
  39. email,
  40. notification,
  41. order,
  42. payment,
  43. plugin,
  44. product,
  45. provider,
  46. proxy,
  47. slot,
  48. sms,
  49. task,
  50. ticket,
  51. user,
  52. vas_task,
  53. webhook,
  54. ]
  55. # 注册所有子模块路由
  56. for _mod in _modules:
  57. if hasattr(_mod, "public_router") and _mod.public_router.routes:
  58. public_router.include_router(_mod.public_router)
  59. if hasattr(_mod, "protected_router") and _mod.protected_router.routes:
  60. protected_router.include_router(_mod.protected_router)
  61. if hasattr(_mod, "admin_required_router") and _mod.admin_required_router.routes:
  62. admin_required_router.include_router(_mod.admin_required_router)