patx/wred
Correct JSON return type and use immutable route method default
Commit cb7592b · patx · 2026-10-15T20:59:14-04:00
Comments
No comments yet.
Diff
diff --git a/wred.py b/wred.py
index 8d35faa..5ee7431 100644
--- a/wred.py
+++ b/wred.py
@@ -54,7 +54,7 @@ class Request:
self._body = b''.join(chunks)
return self._body
- async def json(self) -> dict[str, Any]:
+ async def json(self) -> Any:
"""Parse the request body as JSON."""
body = await self.body()
return orjson.loads(body) if body else {}
@@ -154,7 +154,7 @@ class App:
return await to_thread(read)
- def route(self, path: str, methods: list[str] = ['GET']) -> Callable:
+ def route(self, path: str, methods: list[str] | tuple[str, ...] = ('GET',)) -> Callable:
"""Decorator to register routes with specific HTTP methods."""
def decorator(handler: Callable) -> Callable:
routes = self.pattern_routes if '{' in path and '}' in path else self.routes