]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Add missing `compresslevel` parameter on docs for `GZipMiddleware` (#11350)
authorJun-Ah 준아 <junah.dev@gmail.com>
Thu, 15 Aug 2024 22:38:02 +0000 (07:38 +0900)
committerGitHub <noreply@github.com>
Thu, 15 Aug 2024 22:38:02 +0000 (17:38 -0500)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/en/docs/advanced/middleware.md
docs_src/advanced_middleware/tutorial003.py

index 4b273fd897498b9d624fa08bf47abbabedbf58cf..57e4761673a3a0acb63cf976511966cba0bc398e 100644 (file)
@@ -88,6 +88,7 @@ The middleware will handle both standard and streaming responses.
 The following arguments are supported:
 
 * `minimum_size` - Do not GZip responses that are smaller than this minimum size in bytes. Defaults to `500`.
+* `compresslevel` - Used during GZip compression. It is an integer ranging from 1 to 9. Defaults to `9`. Lower value results in faster compression but larger file sizes, while higher value results in slower compression but smaller file sizes.
 
 ## Other middlewares
 
index b99e3edd19bffe5f96a85399555a6a660b1ac129..e2c87e67d824e481c24b971b4105cae9f9476468 100644 (file)
@@ -3,7 +3,7 @@ from fastapi.middleware.gzip import GZipMiddleware
 
 app = FastAPI()
 
-app.add_middleware(GZipMiddleware, minimum_size=1000)
+app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)
 
 
 @app.get("/")