encode / starlette

The little ASGI framework that shines. 🌟
https://www.starlette.io/
BSD 3-Clause "New" or "Revised" License
10.31k stars 949 forks source link

CompressMiddleware - Supporting ZStd, Brotli, GZip #2564

Closed Zaczero closed 7 months ago

Zaczero commented 8 months ago

Summary

I have always felt like a more robust compression middleware is needed for Starlette. While working one one of my projects, I implemented a robust compression class that supports more than just GZip and has more sane defaults. I decided that it's worth pushing up the upstream so other people can benefit from it.

Today I gave it some polish so it's ready for use in other projects.

I can add markdown documentation when there is a green light for this change. I don't want to put too much effort in something without guarantee.

Key points

Checklist

Zaczero commented 8 months ago

Contributor feedback: I wish the CI runs did not abort each other on first fail, and actually run till the end to produce as much useful information as possible. It's slightly annoying to fix problems one-by-one and then wait few minutes for CI to progress further. For example here, I was not aware of 3.8 issues because 3.11 job aborted it.

Kludex commented 7 months ago

I think this middleware would be great as a third party package.

We can then document it on the https://www.starlette.io/third-party-packages/ page.

Zaczero commented 7 months ago

Sounds good. I'll work on it and then open another PR with the documentation update. If that's fine, I'll close this PR in about a week or two.

Kludex commented 7 months ago

Sounds good. I'll work on it and then open another PR with the documentation update. If that's fine, I'll close this PR in about a week or two.

I'll close it now for housekeeping, but the PR for updating the docs is more than welcome. :)

Kludex commented 7 months ago

@Zaczero Do you mind if I create the third party package myself?

Zaczero commented 7 months ago

@Kludex Slightly yes because I need some more projects for my CV :-) I am getting back home (from 2 weeks away) tomorrow and I'll be able to continue with this topic - I didn't forget about it. Alternatively, we could create a repo where we both hold write perms, I wouldn't mind it. It would be a good opportunity to learn something new from each other. But then, wouldn't it be an overkill.

Kludex commented 7 months ago

I can wait. Let me know when ready so I can recommend.

Zaczero commented 6 months ago

@Kludex https://pypi.org/project/starlette-compress/ https://github.com/Zaczero/starlette-compress

lmk if you want me to update the docs

Zaczero commented 6 months ago

Hey, please let me know if you still want me to update the docs.

Kludex commented 4 months ago

Yes, PR is welcome to add your middleware to the docs. We have a specific page for third party packages like this.