mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-10-29 03:18:14 +08:00
29 lines
888 B
Python
29 lines
888 B
Python
"""
|
|
汇总并注册应用的 API 路由。
|
|
"""
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
def init_routers(app: FastAPI, api_prefix: str = "/api/v1") -> None:
|
|
"""
|
|
初始化路由
|
|
|
|
:param app: 需要挂载路由的 FastAPI 应用
|
|
:param api_prefix: v1 API 根路径,由启动组合根传入
|
|
"""
|
|
from app.api.routers import API_V1_ROUTER_SPECS
|
|
from app.api.servarr import arr_router
|
|
from app.api.servcookie import cookie_router
|
|
# 直接聚合端点路由,避免先构建兼容路由器再克隆到最终应用。
|
|
for spec in API_V1_ROUTER_SPECS:
|
|
app.include_router(
|
|
spec.router,
|
|
prefix=f"{api_prefix}{spec.prefix}",
|
|
tags=list(spec.tags),
|
|
)
|
|
# Radarr、Sonarr路由
|
|
app.include_router(arr_router, prefix="/api/v3")
|
|
# CookieCloud路由
|
|
app.include_router(cookie_router, prefix="/cookiecloud")
|