1 Star 0 Fork 0

s-dy / yogurt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
middleware.go 469 Bytes
一键复制 编辑 原始数据 按行查看 历史
s-dy 提交于 2022-10-22 19:04 . config,encoding, transport
package middleware
import "context"
type Handler func(ctx context.Context, req any) (any, error)
type Middleware func(Handler) Handler
// Chain returns a Middleware that specifies the chained handler for endpoint.
// Middleware按先后顺序执行,则最先的Mid包裹较后的Mid,其暴露在最外
func Chain(m ...Middleware) Middleware {
return func(next Handler) Handler {
for i := len(m) - 1; i >= 0; i-- {
next = m[i](next)
}
return next
}
}
1
https://gitee.com/sdynasty/yogurt.git
git@gitee.com:sdynasty/yogurt.git
sdynasty
yogurt
yogurt
01d4da0b550e

搜索帮助