Skip to content

fix(echo): use built-in compression middleware instead of manual gzip/deflate#230

Closed
BennyFranciscus wants to merge 1 commit intomainfrom
fix/echo-compression-middleware
Closed

fix(echo): use built-in compression middleware instead of manual gzip/deflate#230
BennyFranciscus wants to merge 1 commit intomainfrom
fix/echo-compression-middleware

Conversation

@BennyFranciscus
Copy link
Copy Markdown
Collaborator

What

Replaces hand-rolled compress/gzip and compress/flate writers in the /compression endpoint with Echo's built-in middleware.GzipWithConfig().

Why

Same pattern as #222 (Fiber) — the implementation rules require using framework-level APIs when available. Echo provides middleware.Gzip out of the box, so we should use it instead of hand-rolling compression.

Changes

  • Register middleware.GzipWithConfig(middleware.GzipConfig{Level: 1}) globally
  • Simplify /compression handler to just serve the JSON blob — the middleware handles encoding negotiation and compression automatically
  • Remove unused compress/flate and compress/gzip imports

Note: Echo's built-in middleware only supports gzip (not deflate). Since gcannon sends Accept-Encoding: gzip, deflate and gzip takes priority, this shouldn't affect benchmark results. The middleware short-circuits on endpoints where no Accept-Encoding header is present, so overhead on other tests should be negligible.

Fixes #229

…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
@BennyFranciscus
Copy link
Copy Markdown
Collaborator Author

Closing and reopening from my fork — branch protection prevents pushing the go.sum fix directly. New PR incoming.

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.

[Audit] echo: /compression hand-rolls gzip/deflate instead of using Echo middleware

1 participant