package brotli

Import Path
	github.com/andybalholm/brotli (on go.dev)

Dependency Relation
	imports 11 packages, and imported by one package


Code Examples { proverbs := []string{ "Don't communicate by sharing memory, share memory by communicating.\n", "Concurrency is not parallelism.\n", "The bigger the interface, the weaker the abstraction.\n", "Documentation is for users.\n", } var b bytes.Buffer bw := NewWriter(nil) br := NewReader(nil) for _, s := range proverbs { b.Reset() bw.Reset(&b) if _, err := io.WriteString(bw, s); err != nil { log.Fatal(err) } if err := bw.Close(); err != nil { log.Fatal(err) } if err := br.Reset(&b); err != nil { log.Fatal(err) } if _, err := io.Copy(os.Stdout, br); err != nil { log.Fatal(err) } } }
Package-Level Type Names (total 3)
/* sort by: | */
(*Reader) Read(p []byte) (n int, err error) Reset discards the Reader's state and makes it equivalent to the result of its original state from NewReader, but reading from src instead. This permits reusing a Reader rather than allocating a new one. Error is always nil *Reader : io.Reader func NewReader(src io.Reader) *Reader
Close flushes remaining data to the decorated writer. Flush outputs encoded data for all input provided to Write. The resulting output can be decoded to match all input before Flush, but the stream is not yet complete until after Close. Flush has a negative impact on compression. Reset discards the Writer's state and makes it equivalent to the result of its original state from NewWriter or NewWriterLevel, but writing to dst instead. This permits reusing a Writer rather than allocating a new one. Write implements io.Writer. Flush or Close must be called to ensure that the encoded bytes are actually flushed to the underlying Writer. *Writer : github.com/valyala/fasthttp/stackless.Writer *Writer : internal/bisect.Writer *Writer : io.Closer *Writer : io.WriteCloser *Writer : io.Writer func NewWriter(dst io.Writer) *Writer func NewWriterLevel(dst io.Writer, level int) *Writer func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer
WriterOptions configures Writer. LGWin is the base 2 logarithm of the sliding window size. Range is 10 to 24. 0 indicates automatic configuration based on Quality. Quality controls the compression-speed vs compression-density trade-offs. The higher the quality, the slower the compression. Range is 0 to 11. func NewWriterOptions(dst io.Writer, options WriterOptions) *Writer
Package-Level Functions (total 5)
HTTPCompressor chooses a compression method (brotli, gzip, or none) based on the Accept-Encoding header, sets the Content-Encoding header, and returns a WriteCloser that implements that compression. The Close method must be called before the current HTTP handler returns.
NewReader creates a new Reader reading the given reader.
Writes to the returned writer are compressed and written to dst. It is the caller's responsibility to call Close on the Writer when done. Writes may be buffered and not flushed until Close.
NewWriterLevel is like NewWriter but specifies the compression level instead of assuming DefaultCompression. The compression level can be DefaultCompression or any integer value between BestSpeed and BestCompression inclusive.
NewWriterOptions is like NewWriter but specifies WriterOptions
Package-Level Constants (total 3)
const BestCompression = 11
const BestSpeed = 0