encoding

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 13 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 Encodings

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

func NewEncodings

func NewEncodings(errlog logs.Logger) *Encodings

func (*Encodings) Add

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

Allow 实现了 server.Encodings.Add

func (*Encodings) Allow

func (c *Encodings) Allow(contentType string, id ...string)

Allow 实现了 server.Encodings.Allow

func (*Encodings) Search

func (c *Encodings) Search(contentType, h string) (w *Pool, 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 Pool

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

Pool 压缩对象池

每个 Pool 对象与特定的压缩对象关联,可以复用这些压缩对象。

func (*Pool) Get

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

func (*Pool) Name

func (p *Pool) Name() string

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