Request Data Extractors are responsible for converting framework-specific request objects into a RequestData container.
Implementation Details:
- Sync vs Async: Methods like
_get_path_params, _get_query_params, _get_headers, and _get_cookies are synchronous. Only _get_body, _get_form_data, and _get_files are implemented as asynchronous methods in the BaseAsyncRequestDataExtractor. - Framework Specifics: Each framework (e.g., Starlette, Flask) provides its own implementation (e.g.,
StarletteRequestDataExtractor). - Input: The
_get_* methods receive the raw framework request object, not the RequestEnvelope.
class BaseAsyncRequestDataExtractor(BaseRequestDataExtractor, ABC):
"""Base async extractor — overrides only body/form/files as async"""
@classmethod
@abstractmethod
async def _get_body(cls, request: Any) -> bytes | str | dict: ...
@classmethod
@abstractmethod
async def _get_form_data(cls, request: Any) -> dict: ...
@classmethod
@abstractmethod
async def _get_files(cls, request: Any) -> dict: ...
@classmethod
async def extract_request_data(cls, env: RequestEnvelope) -> RequestData:
request = env.request
return RequestData(
path_params=env.path_params or cls._get_path_params(request),
query_params=cls._get_query_params(request), # sync
headers=cls._normalize_headers(cls._get_headers(request)), # sync
cookies=cls._get_cookies(request), # sync
body=await cls._get_body(request), # async
form_data=await cls._get_form_data(request), # async
files=await cls._get_files(request), # async
)