Refactor router dependency wiring to explicit app state providers

This commit is contained in:
2026-04-06 20:12:04 +02:00
parent f0ee466603
commit 594f55d157
5 changed files with 45 additions and 59 deletions

View File

@@ -121,16 +121,15 @@ async def create_blocklist(
summary="Trigger a manual blocklist import",
)
async def run_import_now(
request: Request,
http_session: HttpSessionDep,
db: DbDep,
_auth: AuthDep,
http_session: HttpSessionDep,
socket_path: Fail2BanSocketDep,
) -> ImportRunResult:
"""Download and apply all enabled blocklist sources immediately.
Args:
request: Incoming request (used to access shared HTTP session).
http_session: Shared HTTP session (injected).
db: Application database connection (injected).
_auth: Validated session — enforces authentication.
@@ -155,7 +154,6 @@ async def run_import_now(
summary="Get the current import schedule",
)
async def get_schedule(
request: Request,
db: DbDep,
_auth: AuthDep,
scheduler: SchedulerDep,
@@ -188,10 +186,10 @@ async def get_schedule(
)
async def update_schedule(
payload: ScheduleConfig,
request: Request,
db: DbDep,
_auth: AuthDep,
scheduler: SchedulerDep,
request: Request,
) -> ScheduleInfo:
"""Persist a new schedule configuration and reschedule the import job.
@@ -342,7 +340,7 @@ async def delete_blocklist(
)
async def preview_blocklist(
source_id: int,
request: Request,
http_session: HttpSessionDep,
db: DbDep,
_auth: AuthDep,
) -> PreviewResponse:
@@ -365,7 +363,6 @@ async def preview_blocklist(
if source is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Blocklist source not found.")
http_session: aiohttp.ClientSession = request.app.state.http_session
try:
return await blocklist_service.preview_source(source.url, http_session)
except ValueError as exc: