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

Introduce MatchSupportedRequestFn option for more granular decision making process to compress a response #57

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

Conversation

thekondor
Copy link

Rationale

WithMatchSupportedRequestFn option is introduced. This allows to make a decision about response compression basing on a combination of other headers and values from a request (like #42).

Changes

  • No breaking changes in API for existing clients
  • No breaking changes in behavior for existing clients
  • WithMatchSupportedRequestFn() accepts a function with a signature: func(req *http.Request) (ok bool, supported bool). The first returned ok value is a marker that no other checks if a compression is excluded should be applied: supported is a decision for compression.
  • MatchSupportedRequestFn has a precedence over Excluded{Extensions,Paths,PathesRegexs} lists. If ok is false, the other (= the mentioned before) exclusion rules are applied.

Notes

  • http.Request is used intentionally instead of, say, gin.Context. The goal is to have a safe limited interface.
  • In general, existing exclusion lists could be re-implemented in the future through the newly added interface.

@thekondor thekondor marked this pull request as ready for review May 6, 2022 10:31
@hollow hollow deleted the request-based-decision-to-compress branch December 5, 2023 16:30
@appleboy
Copy link
Member

appleboy commented May 2, 2024

@thekondor Can you resolve conflicts?

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.

None yet

2 participants