Skip to content

feat(middleware): compress all text/* types by default#1057

Open
acme wants to merge 1 commit into
go-chi:masterfrom
acme:acme/compress-all-text-types
Open

feat(middleware): compress all text/* types by default#1057
acme wants to merge 1 commit into
go-chi:masterfrom
acme:acme/compress-all-text-types

Conversation

@acme

@acme acme commented Mar 4, 2026

Copy link
Copy Markdown
  • Replace explicit text/html, text/css, text/plain, text/javascript entries in defaultCompressibleContentTypes with a single text/* wildcard
  • Fix NewCompressor to parse wildcard patterns in the defaults path, not only when types are explicitly passed
  • Add test asserting text/markdown is gzip-compressed with default settings

I realise there have been a number of compression-related pull requests in the past, but hopefully this is small enough and has tests so is easy to merge in.

- Replace explicit `text/html`, `text/css`, `text/plain`,
  `text/javascript` entries in `defaultCompressibleContentTypes`
  with a single `text/*` wildcard
- Fix `NewCompressor` to parse wildcard patterns in the defaults
  path, not only when types are explicitly passed
- Add test asserting `text/markdown` is gzip-compressed with default
  settings
@JRaspass

JRaspass commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This needs a rebase but other than that seems like a really nice improvement that brings symmetry between user-supplied and default compression content types. I wonder if we might even be able to merge the loops now that they both support wildcards?

What do you think of this change @VojtechVitek ?

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.

2 participants