1 Star 2 Fork 0

阿债 / fiber-u8l

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
expvar.go 737 Bytes
一键复制 编辑 原始数据 按行查看 历史
阿债 提交于 2023-02-09 16:54 . 同步更新fiber到2.42.0
package expvar
import (
"strings"
"gitee.com/azhai/fiber-u8l/v2"
"github.com/valyala/fasthttp/expvarhandler"
)
// New creates a new middleware handler
func New(config ...Config) fiber.Handler {
// Set default config
cfg := configDefault(config...)
// Return new handler
return func(c *fiber.Ctx) error {
// Don't execute middleware if Next returns true
if cfg.Next != nil && cfg.Next(c) {
return c.Next()
}
path := c.Path()
// We are only interested in /debug/vars routes
if len(path) < 11 || !strings.HasPrefix(path, "/debug/vars") {
return c.Next()
}
if path == "/debug/vars" {
expvarhandler.ExpvarHandler(c.Context())
return nil
}
return c.Redirect("/debug/vars", fiber.StatusFound)
}
}
1
https://gitee.com/azhai/fiber-u8l.git
git@gitee.com:azhai/fiber-u8l.git
azhai
fiber-u8l
fiber-u8l
v2.51.0

搜索帮助