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

Brotli compression not working #868

Open
mateors opened this issue Oct 25, 2023 · 0 comments
Open

Brotli compression not working #868

mateors opened this issue Oct 25, 2023 · 0 comments

Comments

@mateors
Copy link

mateors commented Oct 25, 2023

import brotli_enc "gopkg.in/kothar/brotli-go.v0/enc"

compressor := middleware.NewCompressor(5, "text/html")
compressor.SetEncoder("br", func(w http.ResponseWriter, level int) io.Writer {
  params := brotli_enc.NewBrotliParams()
  params.SetQuality(level)
  return brotli_enc.NewBrotliWriter(params, w)
})

the above code shows error, but following seems working but compression not working what's wrong?

	r := chi.NewRouter() //chi.NewMux()
	//r.Use(middleware.Logger)

	compressor := middleware.NewCompressor(5, "/*") //"/*"
	compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
		params := brotli_enc.NewBrotliParams()
		params.SetQuality(level)
		return brotli_enc.NewBrotliWriter(params, w)
	})
	r.Use(compressor.Handler) //
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

No branches or pull requests

1 participant