Files
robertvoy-ComfyUI-Distributed/api/endpoint_policy.py
T
Robert Wojciechowski 3058b11ff2 Remove list splitter/collector feature and refactor distributed modules
- Remove DistributedListSplitter and DistributedListCollector nodes
- Remove /distributed/init_list_queue and /distributed/request_list_item endpoints
- Clean up all references from prompt_transform, queue_orchestration, constants, and tests
- Refactor and reorganize distributed modules for quality improvements
2026-03-07 05:22:09 +00:00

26 lines
808 B
Python

"""Shared endpoint policy helpers for distributed API routes."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from aiohttp import web
from ..utils.network import handle_api_error
from .request_guards import authorization_error_or_none
async def run_authorized_endpoint(
request: web.Request,
operation: Callable[[], Awaitable[web.StreamResponse]],
*,
unexpected_status: int = 500,
) -> web.StreamResponse:
"""Run endpoint operation with shared auth guard and fallback error mapping."""
auth_error = await authorization_error_or_none(request)
if auth_error is not None:
return auth_error
try:
return await operation()
except Exception as exc:
return await handle_api_error(request, exc, unexpected_status)