adriangb / xpresso

A composable Python ASGI web framework
https://xpresso-api.dev/
MIT License
178 stars 4 forks source link

feat: add a `consume: bool = True` parameter to body Binders #4

Closed adriangb closed 2 years ago

adriangb commented 2 years ago

This will allow users to control if they want the body consumed or not. Generally, if you are reading the entire request body into a Pydantic model you no longer care about the body. So by default (as we currently do) we will consume the body. But this will give users the option to not consume the body, at the cost of performance and memory consumption.

Expected usage:

async def endponit(body: Annoatated[List[str], Json(consume=False)]):  ....