From 44493aad2a86c42b7eec127c8e047d0863f82437 Mon Sep 17 00:00:00 2001 From: GabrielBarberini Date: Thu, 13 Jun 2024 20:06:42 -0300 Subject: [PATCH] implements gzpi middleware for payloads above 1kb --- lib/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api.py b/lib/api.py index e91e166..b6af499 100644 --- a/lib/api.py +++ b/lib/api.py @@ -5,6 +5,7 @@ from fastapi import FastAPI, Request, status from fastapi.exceptions import RequestValidationError from fastapi.middleware.cors import CORSMiddleware +from fastapi.middleware.gzip import GZipMiddleware from fastapi.openapi.utils import get_openapi from fastapi.responses import RedirectResponse, JSONResponse @@ -29,6 +30,9 @@ app.include_router(motor.router) app.include_router(rocket.router) +# Compress responses above 1KB +app.add_middleware(GZipMiddleware, minimum_size=1000) + def custom_openapi(): if app.openapi_schema: