encoding

package
v0.76.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package encoding 处理 Accept-encoding 报头内容

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alg added in v0.70.0

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

func (*Alg) Get added in v0.70.0

func (p *Alg) Get(w io.Writer) io.WriteCloser

func (*Alg) Name added in v0.70.0

func (p *Alg) Name() string

type Encodings

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

func NewEncodings

func NewEncodings(errlog logs.Logger) *Encodings

func (*Encodings) Add

func (c *Encodings) Add(name string, f NewEncodingFunc, contentType ...string)

Add 添加一种压缩算法

name 算法名称,可以重复;

func (*Encodings) Search

func (c *Encodings) Search(contentType, h string) (w *Alg, notAcceptable bool)

Search 从报头中查找最合适的算法

如果返回的 w 为空值表示不需要压缩。 当有多个符合时,按添加顺序拿第一个符合条件数据。

type NewEncodingFunc

type NewEncodingFunc func() WriteCloseRester

func BrotliWriter

func BrotliWriter(o brotli.WriterOptions) NewEncodingFunc

BrotliWriter br

func CompressWriter

func CompressWriter(order lzw.Order, width int) NewEncodingFunc

CompressWriter compress

func DeflateWriter

func DeflateWriter(level int) NewEncodingFunc

DeflateWriter deflate

func GZipWriter

func GZipWriter(level int) NewEncodingFunc

GZipWriter gzip

func ZstdWriter added in v0.59.0

func ZstdWriter(o ...zstd.EOption) NewEncodingFunc

ZstdWriter zstd

type WriteCloseRester

type WriteCloseRester interface {
	io.WriteCloser
	Reset(io.Writer)
}

WriteCloseRester 每种压缩实例需要实现的最小接口

Jump to

Keyboard shortcuts

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