fix(echo): use built-in compression middleware instead of manual gzip/deflate#230
Closed
BennyFranciscus wants to merge 1 commit intomainfrom
Closed
fix(echo): use built-in compression middleware instead of manual gzip/deflate#230BennyFranciscus wants to merge 1 commit intomainfrom
BennyFranciscus wants to merge 1 commit intomainfrom
Conversation
…zip/deflate Replace hand-rolled compress/gzip and compress/flate writers in the /compression endpoint with Echo's built-in middleware.GzipWithConfig() registered globally at level 1. This matches the framework-level API rule — Echo provides a documented gzip middleware, so we use it. The middleware handles Accept-Encoding negotiation automatically. For non-compression endpoints, the middleware short-circuits when no Accept-Encoding header is present. Fixes #229
Collaborator
Author
|
Closing and reopening from my fork — branch protection prevents pushing the go.sum fix directly. New PR incoming. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces hand-rolled
compress/gzipandcompress/flatewriters in the/compressionendpoint with Echo's built-inmiddleware.GzipWithConfig().Why
Same pattern as #222 (Fiber) — the implementation rules require using framework-level APIs when available. Echo provides
middleware.Gzipout of the box, so we should use it instead of hand-rolling compression.Changes
middleware.GzipWithConfig(middleware.GzipConfig{Level: 1})globally/compressionhandler to just serve the JSON blob — the middleware handles encoding negotiation and compression automaticallycompress/flateandcompress/gzipimportsNote: Echo's built-in middleware only supports gzip (not deflate). Since gcannon sends
Accept-Encoding: gzip, deflateand gzip takes priority, this shouldn't affect benchmark results. The middleware short-circuits on endpoints where noAccept-Encodingheader is present, so overhead on other tests should be negligible.Fixes #229