compress

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package compress 提供一个支持内容压缩的中间件

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBrotli added in v1.7.0

func NewBrotli(w io.Writer) (io.WriteCloser, error)

NewBrotli 新建 br 算法

func NewDeflate

func NewDeflate(w io.Writer) (io.WriteCloser, error)

NewDeflate 新建 deflate 算法

func NewGzip

func NewGzip(w io.Writer) (io.WriteCloser, error)

NewGzip 新建 gzip 算法

Types

type Compress added in v1.7.0

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

Compress 提供压缩功能的中件间

func New

func New(next http.Handler, opt *Options) *Compress

New 构建一个支持压缩的中间件

将 opt 传递给 New 之后,再修改 opt 中的值,将不再启作用。

func (*Compress) ServeHTTP added in v1.7.0

func (c *Compress) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Options

type Options struct {
	// Funcs 指定压缩名称对应的生成函数
	Funcs map[string]WriterFunc

	// 如果指定了这个值,那么会把错误日志输出到此。
	// 若未指定,则不输出内容。
	ErrorLog *log.Logger

	// 仅对该表中的类型进行压缩
	//
	// 可以用通配符 * 作为结尾:
	// text* 表示以 text 开头的 mimetype;
	// 其它类型的值,表示完全匹配。
	Types []string
	// contains filtered or unexported fields
}

Options New 的参数

type WriterFunc

type WriterFunc func(w io.Writer) (io.WriteCloser, error)

WriterFunc 定义了将一个 io.Writer 声明为具有压缩功能的 io.WriteCloser

Directories

Path Synopsis
Package accept 用于处理 accpet 系列的报头 Deprecated: 已不在使用,请使用 qheader 包的相关内容
Package accept 用于处理 accpet 系列的报头 Deprecated: 已不在使用,请使用 qheader 包的相关内容

Jump to

Keyboard shortcuts

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