compress

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 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

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

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

Compress 提供压缩功能的中件间

func New

func New(errlog *log.Logger, writers map[string]WriterFunc, types ...string) *Compress

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

types 表示需要进行压缩处理的 mimetype 类型,可以是以下格式:

  • application/json 具体类型;
  • text* 表示以 text 开头的所有类型;
  • * 表示所有类型,一旦指定此值,则其它设置都将被忽略;

func (*Compress) Middleware

func (c *Compress) Middleware(next http.Handler) http.Handler

Middleware 将当前中间件应用于 next

func (*Compress) MiddlewareFunc

func (c *Compress) MiddlewareFunc(next func(w http.ResponseWriter, r *http.Request)) http.Handler

MiddlewareFunc 将当前中间件应用于 next

type WriterFunc

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

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

Jump to

Keyboard shortcuts

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