"""Route helper wrappers.""" from __future__ import annotations from collections.abc import Callable from typing import Any from backend.dto.common import response_from_exception, success_response from core.identity import RequestContext def handle_request(ctx: RequestContext, callback: Callable[[], Any]) -> dict[str, Any]: try: return success_response(callback(), request_id=ctx.request_id) except Exception as exc: return response_from_exception(exc, request_id=ctx.request_id)