Allowed module routes to return static file responses.

This commit is contained in:
2026-02-15 09:15:01 -05:00
parent 067b7c5a0a
commit d55bc2a762
4 changed files with 7 additions and 7 deletions
+1 -1
Submodule docs updated: 268e3c839a...df285f62d9
+2 -2
View File
@@ -38,9 +38,9 @@ class RouteMark(TypedDict):
methods: list[str] | None
# Handler type: receives RouteContext, returns web.Response or dict (auto-JSON).
# Handler type: receives RouteContext, returns a response or dict (auto-JSON).
type RouteHandler = (
"Callable[[RouteContext], Awaitable[web.Response | dict[str, Any] | None]]"
"Callable[[RouteContext], Awaitable[web.StreamResponse | dict[str, Any] | None]]"
)
+1 -1
View File
@@ -162,6 +162,6 @@ class HttpServer:
return web.Response(status=202)
async def _handle_catch_all(self, request: web.Request) -> web.Response:
async def _handle_catch_all(self, request: web.Request) -> web.StreamResponse:
"""Delegate module route requests to the RouteDispatcher."""
return await self._route_dispatcher.dispatch(request)
+3 -3
View File
@@ -330,7 +330,7 @@ class RouteDispatcher:
"""
return self._route_registry.unregister_by_module(module_name)
async def dispatch(self, request: web.Request) -> web.Response:
async def dispatch(self, request: web.Request) -> web.StreamResponse:
"""
Dispatch an HTTP request to the appropriate module route handler.
@@ -371,7 +371,7 @@ class RouteDispatcher:
request: web.Request,
route_info: RouteInfo,
match_info: dict[str, str] | None = None,
) -> web.Response:
) -> web.StreamResponse:
"""
Handle an HTTP request to a module-registered route.
@@ -418,7 +418,7 @@ class RouteDispatcher:
if result is None:
return web.Response(status=204) # No Content.
elif isinstance(result, web.Response):
elif isinstance(result, web.StreamResponse):
return result
elif isinstance(result, dict):
return web.json_response(result)