Update compress middleware support Brotli support documentation (#1007)
* update documentation on brotli compressor support to use Google's brotli package * fix import statement, add Cgo-free alternative * reset accidental file mod
This commit is contained in:
parent
87c34a24a6
commit
735ae2b87f
1 changed files with 12 additions and 4 deletions
|
|
@ -148,13 +148,21 @@ func NewCompressor(level int, types ...string) *Compressor {
|
|||
//
|
||||
// For example, add the Brotli algorithm:
|
||||
//
|
||||
// import brotli_enc "gopkg.in/kothar/brotli-go.v0/enc"
|
||||
// import "github.com/google/brotli/go/cbrotli"
|
||||
//
|
||||
// compressor := middleware.NewCompressor(5, "text/html")
|
||||
// compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
|
||||
// params := brotli_enc.NewBrotliParams()
|
||||
// params.SetQuality(level)
|
||||
// return brotli_enc.NewBrotliWriter(params, w)
|
||||
// return cbrotli.NewWriter(w, cbrotli.WriterOptions{Quality: level})
|
||||
// })
|
||||
//
|
||||
// Alternatively, this Cgo-free Brotli module can be used:
|
||||
//
|
||||
// import "github.com/andybalholm/brotli"
|
||||
//
|
||||
// compressor := middleware.NewCompressor(5, "text/html")
|
||||
//
|
||||
// compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
|
||||
// return brotli.NewWriterV2(w, level)
|
||||
// })
|
||||
func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) {
|
||||
encoding = strings.ToLower(encoding)
|
||||
|
|
|
|||
Loading…
Reference in a new issue