docs/examples/onboarding/django/header_cookie_params.py
raw| 1 | from typing import Annotated |
| 2 | |
| 3 | from litestar import Litestar, get |
| 4 | from litestar.params import CookieParameter, HeaderParameter |
| 5 | |
| 6 | |
| 7 | @get("/") |
| 8 | async def handler( |
| 9 | session_id: Annotated[str, CookieParameter(name="sessionid")], |
| 10 | api_key: Annotated[str, HeaderParameter(name="X-API-Key")], |
| 11 | ) -> dict[str, str]: |
| 12 | return {"session": session_id, "api_key": api_key} |
| 13 | |
| 14 | |
| 15 | app = Litestar(route_handlers=[handler]) |