### Install Source: https://github.com/cafxx/httpcompression/blob/master/README.md Install the httpcompression package using go get. ```bash go get github.com/CAFxX/httpcompression ``` -------------------------------- ### Usage Example Source: https://github.com/cafxx/httpcompression/blob/master/README.md Example of how to use httpcompression.DefaultAdapter to wrap an HTTP handler for transparent response body compression. ```go package main import ( "io" "net/http" "github.com/CAFxX/httpcompression" ) func main() { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") io.WriteString(w, "Hello, World") }) compress, _ := httpcompression.DefaultAdapter() // Use the default configuration http.Handle("/", compress(handler)) http.ListenAndServe("0.0.0.0:8080", nil) } ``` -------------------------------- ### Custom compressor example Source: https://github.com/cafxx/httpcompression/blob/master/README.md Example of using a custom compressor implementation (pgzip) for the "gzip" content-encoding. ```go pgz, err := httpcompression.Compressor("gzip", 0, pgzip.New(pgzip.Options{Level: 6})) if err != nil { log.Fatal(err) } compress, err := httpcompression.Adapter( // use klauspost/pgzip as compressor for the "gzip" content-encoding, with priority 0 pgz, ) if err != nil { log.Fatal(err) } http.Handle("/", compress(handler)) ``` -------------------------------- ### Benchmark Command Source: https://github.com/cafxx/httpcompression/blob/master/results.md Command used to generate the benchmark results. ```bash benchstat -html <(go test -count=5 -benchtime=0.2s -bench=././././serial) >results.md ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.