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

feat(encoding): use an extension for encoding, which allow a specific handler to disable compression if needed #3534

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joelwurtz
Copy link
Contributor

@joelwurtz joelwurtz commented Dec 16, 2024

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

This PR aims to have better control of the compression middleware.

Actually the compression middleware will always encode the response once it used, however there is some case where we don't want compression, some middleware force the accept encoding to avoid this, but there is no possibility to prevent compression once it has been calculated.

With this PR, new middleware will have the ability to avoid compression just by inserting a Identity encoding into the extensions_mut of the request.

Also an user would be able to avoid compression a request by removing this data from the request extension (or setting it to identity)

Also this would allow other middleware that are after the compression middleware to still correctly handle the compression without end user needing to take care of the middleware order

Will finalize this PR if feature is accepted

@joelwurtz joelwurtz force-pushed the feat/encoding-as-extension branch from 58afa83 to 0cb453e Compare December 16, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant