Documentation ¶
Overview ¶
Package compress 提供一个支持内容压缩的中间件
Index ¶
- func NewBrotli(w io.Writer) (io.WriteCloser, error)
- func NewDeflate(w io.Writer) (io.WriteCloser, error)
- func NewGzip(w io.Writer) (io.WriteCloser, error)
- type Compress
- func (c *Compress) AddType(types ...string)
- func (c *Compress) DeleteType(types ...string)
- func (c *Compress) Middleware(next http.Handler) http.Handler
- func (c *Compress) MiddlewareFunc(next func(w http.ResponseWriter, r *http.Request)) http.Handler
- func (c *Compress) SetWriter(name string, w WriterFunc)
- type WriterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compress ¶
type Compress struct {
// contains filtered or unexported fields
}
Compress 提供压缩功能的中件间
func New ¶
New 构建一个支持压缩的中间件
types 表示需要进行压缩处理的 mimetype 类型,可以是以下格式:
- application/json 具体类型;
- text* 表示以 text 开头的所有类型;
- * 表示所有类型,一旦指定此值,则其它设置都将被忽略;
func (*Compress) AddType ¶ added in v2.4.0
AddType 添加对媒体类型的支持
types 表示需要进行压缩处理的 mimetype 类型,可以是以下格式:
- application/json 具体类型;
- text* 表示以 text 开头的所有类型;
- * 表示所有类型,一旦指定此值,则其它设置都将被忽略;
func (*Compress) Middleware ¶
Middleware 将当前中间件应用于 next
func (*Compress) MiddlewareFunc ¶
MiddlewareFunc 将当前中间件应用于 next
func (*Compress) SetWriter ¶ added in v2.4.0
func (c *Compress) SetWriter(name string, w WriterFunc)
SetWriter 设置压缩算法
如果 w 为 nil,则表示去掉此算法的支持。
type WriterFunc ¶
type WriterFunc func(w io.Writer) (io.WriteCloser, error)
WriterFunc 定义了将一个 io.Writer 声明为具有压缩功能的 io.WriteCloser
Click to show internal directories.
Click to hide internal directories.