middleware

package
v5.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package middleware 中间件管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(h http.Handler, f ...Func) http.Handler

Apply 按顺序将所有的中间件应用于 h

Types

type Func

type Func func(http.Handler) http.Handler

Func 将一个 http.Handler 封装成另一个 http.Handler

type Middlewares

type Middlewares struct {
	http.Handler
	// contains filtered or unexported fields
}

Middlewares 中间件管理

func NewMiddlewares

func NewMiddlewares(next http.Handler) *Middlewares

NewMiddlewares 声明新的 Middlewares 实例

func (*Middlewares) Append

func (ms *Middlewares) Append(f Func) *Middlewares

Append 添加中间件到尾部

尾部的中间件将最后被调用,多次添加,则最后一次的在最末尾。

func (*Middlewares) Prepend

func (ms *Middlewares) Prepend(m Func) *Middlewares

Prepend 添加中间件到顶部

顶部的中间件在运行过程中将最早被调用,多次添加,则最后一次的在顶部。

func (*Middlewares) Reset

func (ms *Middlewares) Reset() *Middlewares

Reset 清除中间件

Jump to

Keyboard shortcuts

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