Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Adds gzip compression to HTTP responses, dramatically improving load times. #4709

Merged
merged 19 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1754b2d
feature: Adds gzip compression to HTTP responses
May 10, 2024
7efa373
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 11, 2024
15229b1
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 13, 2024
69d645c
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 14, 2024
8cb8056
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 15, 2024
fde1606
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 16, 2024
7ac7762
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 20, 2024
ba0411f
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 22, 2024
01e527e
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 28, 2024
ab989cc
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 29, 2024
ab0d19e
Merge branch 'master' into adds-gzip-compression
Meandmybadself May 30, 2024
60deeda
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 3, 2024
17be175
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 7, 2024
b109afb
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 10, 2024
f9b408f
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 14, 2024
bcd00c6
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 16, 2024
d020bb7
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 26, 2024
ab86ada
Merge branch 'master' into adds-gzip-compression
Meandmybadself Jun 26, 2024
85a28d2
Merge branch 'master' into adds-gzip-compression
whitdog47 Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/dispatch/main.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.routing import compile_path
from starlette.middleware.gzip import GZipMiddleware

from starlette.responses import Response, StreamingResponse, FileResponse
from starlette.staticfiles import StaticFiles
@@ -54,10 +55,11 @@ async def not_found(request, exc):
app = FastAPI(exception_handlers=exception_handlers, openapi_url="")
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
app.add_middleware(GZipMiddleware, minimum_size=1000)

# we create the ASGI for the frontend
frontend = FastAPI(openapi_url="")

frontend.add_middleware(GZipMiddleware, minimum_size=1000)

@frontend.middleware("http")
async def default_page(request, call_next):
@@ -77,6 +79,7 @@ async def default_page(request, call_next):
openapi_url="/docs/openapi.json",
redoc_url="/docs",
)
api.add_middleware(GZipMiddleware, minimum_size=1000)


def get_path_params_from_request(request: Request) -> str: