Skip to content

A custom ASGI middleware for starlette to handle GZipped HTTP Requests

License

Notifications You must be signed in to change notification settings

RazCrimson/starlette-gzip-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

starlette-gzip-request

starlette-gzip-request is a custom middleware for supporting HTTP requests compressed with Gzip in Starlette.

This package essentially aims to fill the need presented in encode/starlette#644.

  • Python 3.8+ support
  • Compatible with asyncio and trio backends

Installation

pip install starlette-gzip-request

Basic Usage

Starlette

from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette_gzip_request import GzipRequestMiddleware

middleware = [
    Middleware(GzipRequestMiddleware)
]

app = Starlette(routes=..., middleware=middleware)

FastAPI

starlette-gzip-request can also be used with FastAPI as follows:

from fastapi import FastAPI
from starlette_gzip_request import GzipRequestMiddleware

app = FastAPI()
app.add_middleware(GzipRequestMiddleware)

Contributing

If you'd like to contribute, please feel free to open a pull request (PR).

Please ensure that your PRs include test coverage to validate your changes. Thank you for helping improve starlette-gzip-request!

Authors