Documentation ¶
Index ¶
- Variables
- func GinBasicAuth(args ...string) gin.HandlerFunc
- func GinLogMiddleware() gin.HandlerFunc
- func GinRatelimitMiddleware() gin.HandlerFunc
- func GinRecovery(...) gin.HandlerFunc
- func InitWithConfigFile(configFile string)
- func NewGinEngine(middlewares ...gin.HandlerFunc) *gin.Engine
- func PromExporterHandler(collectors ...prometheus.Collector) gin.HandlerFunc
- func Run(app http.Handler)
Constants ¶
This section is empty.
Variables ¶
View Source
var TemplFuncs = map[string]interface{}{ "StrContains": func(s, substr string) bool { return strings.Contains(s, substr) }, "StrContainsAny": func(s, chars string) bool { return strings.ContainsAny(s, chars) }, "StrContainsRune": func(s string, r rune) bool { return strings.ContainsRune(s, r) }, "StrCount": func(s, sep string) int { return strings.Count(s, sep) }, "StrEqualFold": func(s, t string) bool { return strings.EqualFold(s, t) }, "StrFields": func(s string) []string { return strings.Fields(s) }, "StrFieldsFunc": func(s string, f func(rune) bool) []string { return strings.FieldsFunc(s, f) }, "StrHasPrefix": func(s, prefix string) bool { return strings.HasPrefix(s, prefix) }, "StrHasSuffix": func(s, suffix string) bool { return strings.HasSuffix(s, suffix) }, "StrIndex": func(s, sep string) int { return strings.Index(s, sep) }, "StrIndexAny": func(s, chars string) int { return strings.IndexAny(s, chars) }, "StrIndexByte": func(s string, c byte) int { return strings.IndexByte(s, c) }, "StrIndexFunc": func(s string, f func(rune) bool) int { return strings.IndexFunc(s, f) }, "StrIndexRune": func(s string, r rune) int { return strings.IndexRune(s, r) }, "StrJoin": func(a []string, sep string) string { return strings.Join(a, sep) }, "StrLastIndex": func(s, sep string) int { return strings.LastIndex(s, sep) }, "StrLastIndexAny": func(s, chars string) int { return strings.LastIndexAny(s, chars) }, "StrLastIndexFunc": func(s string, f func(rune) bool) int { return strings.LastIndexFunc(s, f) }, "StrMap": func(mapping func(rune) rune, s string) string { return strings.Map(mapping, s) }, "StrRepeat": func(s string, count int) string { return strings.Repeat(s, count) }, "StrReplace": func(s, old, new string, n int) string { return strings.Replace(s, old, new, n) }, "StrSplit": func(s, sep string) []string { return strings.Split(s, sep) }, "StrSplitAfter": func(s, sep string) []string { return strings.SplitAfter(s, sep) }, "StrSplitAfterN": func(s, sep string, n int) []string { return strings.SplitAfterN(s, sep, n) }, "StrSplitN": func(s, sep string, n int) []string { return strings.SplitN(s, sep, n) }, "StrTitle": func(s string) string { return strings.Title(s) }, "StrToLower": func(s string) string { return strings.ToLower(s) }, "StrToLowerSpecial": func(_case unicode.SpecialCase, s string) string { return strings.ToLowerSpecial(_case, s) }, "StrToTitle": func(s string) string { return strings.ToTitle(s) }, "StrToTitleSpecial": func(_case unicode.SpecialCase, s string) string { return strings.ToTitleSpecial(_case, s) }, "StrToUpper": func(s string) string { return strings.ToUpper(s) }, "StrToUpperSpecial": func(_case unicode.SpecialCase, s string) string { return strings.ToUpperSpecial(_case, s) }, "StrTrim": func(s string, cutset string) string { return strings.Trim(s, cutset) }, "StrTrimFunc": func(s string, f func(rune) bool) string { return strings.TrimFunc(s, f) }, "StrTrimLeft": func(s string, cutset string) string { return strings.TrimLeft(s, cutset) }, "StrTrimLeftFunc": func(s string, f func(rune) bool) string { return strings.TrimLeftFunc(s, f) }, "StrTrimPrefix": func(s, prefix string) string { return strings.TrimPrefix(s, prefix) }, "StrTrimRight": func(s string, cutset string) string { return strings.TrimRight(s, cutset) }, "StrTrimRightFunc": func(s string, f func(rune) bool) string { return strings.TrimRightFunc(s, f) }, "StrTrimSpace": func(s string) string { return strings.TrimSpace(s) }, "StrTrimSuffix": func(s, suffix string) string { return strings.TrimSuffix(s, suffix) }, "IsStrInSlice": goutils.IsStrInSlice, "YiWanString": goutils.YiWanString, }
TemplFuncs is a template.FuncMap with functions that can be used as template actions.
Functions ¶
func GinBasicAuth ¶
func GinBasicAuth(args ...string) gin.HandlerFunc
GinBasicAuth gin 的基础认证中间件 加到 gin app 的路由中可以对该路由添加 basic auth 登录验证 传入 username 和 password 对可以替换默认的 username 和 password
func GinLogMiddleware ¶
func GinLogMiddleware() gin.HandlerFunc
GinLogMiddleware 日志中间件 可根据实际需求自行修改定制
func GinRatelimitMiddleware ¶
func GinRatelimitMiddleware() gin.HandlerFunc
GinRatelimitMiddleware 限频中间件 需先实现对应的 TODO ,可根据实际需求自行修改定制
func GinRecovery ¶
func GinRecovery( recoveryHandler ...func(c *gin.Context, status int, data interface{}, err error, extraMsgs ...interface{}), ) gin.HandlerFunc
GinRecovery gin recovery 中间件 save err in context and abort with recoveryHandler
func InitWithConfigFile ¶
func InitWithConfigFile(configFile string)
InitWithConfigFile 根据 webserver 配置文件初始化 webserver
func NewGinEngine ¶
func NewGinEngine(middlewares ...gin.HandlerFunc) *gin.Engine
NewGinEngine 根据参数创建 gin 的 router engine middlewares 需要使用到的中间件列表,默认不为 engine 添加任何中间件
func PromExporterHandler ¶
func PromExporterHandler(collectors ...prometheus.Collector) gin.HandlerFunc
PromExporterHandler return a handler as the prometheus metrics exporter
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.