Results of 1 - 1 of about 1 for GzipRequest (0.002 sec.)
- Custom Request and APIRoute class 9414
- Custom Request and APIRoute class Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some cases, you may want to override the logic used by the Request and APIRout
...equest bodies. Handling custom request body encodings Let's see how to make use of a custom Request subclass to decompress gzip requests. And an APIRoute subclass to use that custom request class. Create a custom GzipRequest class Tip This is a toy example...to demonstrate how it works, if you need Gzip support, you can use the provided GzipMiddleware . First, we create a GzipRequest class, which will overwrite the Request.body() method to decompress the body in the presence of an appropriate header. If...import Callable , List from fastapi import Body , FastAPI , Request , Response from fastapi.routing import APIRoute class GzipRequest ( Request ): async def body ( self ) -> bytes : if not hasattr ( self , "_body" ): body = await super () . body () if "gzi... - https://man.mtool.work/fastapi/0.115/how-to/custom-request-and-route/
PREV
1
NEXT