5 Star 7 Fork 4

Gitee 极速下载 / cedar-router

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/tungyao/cedar
克隆/下载
middleware.go 590 Bytes
一键复制 编辑 原始数据 按行查看 历史
tungyao 提交于 2021-07-01 14:11 . fix package name
package cedar
type MiddlewareInterceptor func(ResponseWriter, Request, HandlerFunc)
type MiddlewareChain []MiddlewareInterceptor
type MiddlewareHandlerFunc HandlerFunc
func (cont MiddlewareHandlerFunc) Intercept(mw MiddlewareInterceptor) MiddlewareHandlerFunc {
return func(writer ResponseWriter, request Request) {
mw(writer, request, HandlerFunc(cont))
}
}
func (chain MiddlewareChain) Handler(handlerFunc HandlerFunc) HandlerFunc {
curr := MiddlewareHandlerFunc(handlerFunc)
for i := len(chain) - 1; i >= 0; i-- {
curr = curr.Intercept(chain[i])
}
return HandlerFunc(curr)
}
1
https://gitee.com/mirrors/cedar-router.git
git@gitee.com:mirrors/cedar-router.git
mirrors
cedar-router
cedar-router
master

搜索帮助