compression

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingDeflate = "deflate"
)
View Source
const (
	EncodingGzip = "gzip"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	Compress(w io.Writer, data []byte) (int, error)
	Decompress(reader io.ReadCloser) (io.ReadCloser, error)
}

Compressor abstracts the interface for a compression handler.

type Compressors

type Compressors struct {
	// contains filtered or unexported fields
}

func NewCompressors

func NewCompressors() *Compressors

NewCompressors create a Compressors instance.

func (Compressors) AcceptEncoding

func (c Compressors) AcceptEncoding() string

AcceptEncoding returns the Accept-Encoding header with supported compression encodings.

func (Compressors) Compress

func (c Compressors) Compress(w io.Writer, encoding string, data []byte) (int, error)

Compress writes compressed data.

func (Compressors) Decompress

func (c Compressors) Decompress(reader io.ReadCloser, encoding string) (io.ReadCloser, error)

Decompress reads and decompresses the reader with equivalent the content encoding.

func (Compressors) IsEncodingSupported

func (c Compressors) IsEncodingSupported(encoding string) bool

IsEncodingSupported checks if the input encoding is supported.

type DeflateCompressor

type DeflateCompressor struct{}

DeflateCompressor implements the compression handler for deflate encoding.

func (DeflateCompressor) Compress

func (dc DeflateCompressor) Compress(w io.Writer, data []byte) (int, error)

Compress the reader content with gzip encoding.

func (DeflateCompressor) Decompress

func (dc DeflateCompressor) Decompress(reader io.ReadCloser) (io.ReadCloser, error)

Decompress the reader content with gzip encoding.

type GzipCompressor

type GzipCompressor struct{}

GzipCompressor implements the compression handler for gzip encoding.

func (GzipCompressor) Compress

func (gc GzipCompressor) Compress(w io.Writer, data []byte) (int, error)

Compress the reader content with gzip encoding.

func (GzipCompressor) Decompress

func (gc GzipCompressor) Decompress(reader io.ReadCloser) (io.ReadCloser, error)

Decompress the reader content with gzip encoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL