Documentation
¶
Index ¶
- Variables
- type CompressionFormat
- type Compressor
- type Compressors
- func (c Compressors) AcceptEncoding() string
- func (c Compressors) Compress(w io.Writer, encoding string, data io.Reader) (int64, error)
- func (c Compressors) Decompress(reader io.ReadCloser, encoding string) (io.ReadCloser, error)
- func (c Compressors) FindSupportedEncoding(encoding string) CompressionFormat
- func (c Compressors) IsEncodingSupported(encoding string) bool
- type DeflateCompressor
- type GzipCompressor
- type ZstdCompressor
Constants ¶
This section is empty.
Variables ¶
var DefaultCompressor = NewCompressors()
DefaultCompressor the default compressors.
Functions ¶
This section is empty.
Types ¶
type CompressionFormat ¶
type CompressionFormat string
CompressionFormat represents a compression format enumeration.
const ( // EncodingDeflate represents the deflate compression format. EncodingDeflate CompressionFormat = "deflate" )
const ( // EncodingGzip represents the gzip compression format. EncodingGzip CompressionFormat = "gzip" )
const ( // EncodingZstd represents the Zstandard compression format. EncodingZstd CompressionFormat = "zstd" )
type Compressor ¶
type Compressor interface {
Compress(w io.Writer, src io.Reader) (int64, 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
}
Compressors is a general helper for web compression.
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) 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) FindSupportedEncoding ¶
func (c Compressors) FindSupportedEncoding(encoding string) CompressionFormat
FindSupportedEncoding returns the supported encoding from the input string.
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) Decompress ¶
func (dc DeflateCompressor) Decompress(reader io.ReadCloser) (io.ReadCloser, error)
Decompress the reader content with deflate encoding.
type GzipCompressor ¶
type GzipCompressor struct{}
GzipCompressor implements the compression handler for gzip encoding.
func (GzipCompressor) Decompress ¶
func (gc GzipCompressor) Decompress(reader io.ReadCloser) (io.ReadCloser, error)
Decompress the reader content with gzip encoding.
type ZstdCompressor ¶
type ZstdCompressor struct{}
ZstdCompressor implements the compression handler for zstandard encoding.
func (ZstdCompressor) Decompress ¶
func (zc ZstdCompressor) Decompress(reader io.ReadCloser) (io.ReadCloser, error)
Decompress the reader content with zstd encoding.