Skip to content

Commit

Permalink
implements gzpi middleware for payloads above 1kb
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBarberini committed Jun 13, 2024
1 parent f6c96e6 commit 44493aa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 44493aa

Please sign in to comment.