blackbull.middleware.compression¶
blackbull.middleware.compression
¶
Compression
¶
ASGI middleware: compress the response body using the best codec the client accepts (br > zstd > gzip, in server-preference order).
Bodies smaller than min_size bytes are forwarded uncompressed. Responses with already-compressed Content-Types (image/, video/, etc.) are forwarded uncompressed. brotli and zstandard are optional — if not installed the middleware falls back gracefully to gzip or no compression.
BlackBull middleware convention::
from blackbull.middleware import Compression
@app.route(path='/', middlewares=[Compression()])
async def handler(scope, receive, send): ...