Documentation ¶
Index ¶
- Constants
- Variables
- func AliasMiddleware(name string, middleware any)
- func FormatURL(u string) string
- func GetHeaderByName(ctx *Context, key string) string
- func GetLocalIP() string
- func GetRealIP(ctx *Context) (ip string)
- func GetRequestIp(ctx *Context) string
- func IntranetIP() (ips []string, err error)
- func IsIntranetIp(ipStr string) bool
- func MatchPath(ctx *Context, path string, current string) bool
- func MiddlewareGroup(name string, middlewares []any)
- func WithDefaultErrorWriter(writer io.Writer)
- func WithDefaultWriter(writer io.Writer)
- type Accounts
- type Alias
- type Binding
- type BindingBody
- type BindingUri
- type Context
- type Engine
- type Error
- type ErrorType
- type Group
- func (this *Group) Exists(name string) bool
- func (this *Group) Get(name string) *Middlewares
- func (this *Group) Prepend(name string, middleware any) *Group
- func (this *Group) Push(name string, middleware any) *Group
- func (this *Group) Remove(name string)
- func (this *Group) With(name string, middlewares []any) *Group
- type H
- type HandlerFunc
- type HandlersChain
- type IRouter
- type IRoutes
- type LogFormatter
- type LogFormatterParams
- type LoggerConfig
- type Middleware
- func (this *Middleware) AliasMiddleware(name string, middleware any) *Middleware
- func (this *Middleware) GetAlias() *Alias
- func (this *Middleware) GetGlobalMiddlewareList() (middleware []any)
- func (this *Middleware) GetGlobalName() string
- func (this *Middleware) GetGroup() *Group
- func (this *Middleware) GetMiddlewareList(name string) (middleware []any)
- func (this *Middleware) GetMiddlewares() *Middlewares
- func (this *Middleware) MiddlewareGroup(name string, middlewares []any) *Middleware
- func (this *Middleware) PrependMiddleware(middleware any) *Middleware
- func (this *Middleware) PrependMiddlewareToGroup(name string, middleware any) *Middleware
- func (this *Middleware) PushMiddleware(middleware any) *Middleware
- func (this *Middleware) PushMiddlewareToGroup(name string, middleware any) *Middleware
- func (this *Middleware) WithAlias(alias *Alias) *Middleware
- func (this *Middleware) WithGlobalName(globalName string) *Middleware
- func (this *Middleware) WithGroup(group *Group) *Middleware
- func (this *Middleware) WithMiddlewares(middlewares *Middlewares) *Middleware
- type Middlewares
- type Negotiate
- type Param
- type Params
- type RecoveryFunc
- type Render
- type ResponseWriter
- type Route
- type RouteInfo
- type RouteName
- type RouterGroup
- type RouterInfo
- type RouterInfoMap
- type RoutesInfo
- type StructValidator
Constants ¶
const ( // 模式 EnvGinMode = gin.EnvGinMode // 调试模式 DebugMode = gin.DebugMode // 线上模式 ReleaseMode = gin.ReleaseMode // 测试模式 TestMode = gin.TestMode )
Variables ¶
var ( BindingValidator = binding.Validator // ShouldBindBodyWith 使用参数 BindJSON = binding.JSON BindXML = binding.XML BindForm = binding.Form BindQuery = binding.Query BindFormPost = binding.FormPost BindFormMultipart = binding.FormMultipart BindProtoBuf = binding.ProtoBuf BindMsgPack = binding.MsgPack BindYAML = binding.YAML BindUri = binding.Uri BindHeader = binding.Header )
var BasicAuth = gin.BasicAuth
gin.BasicAuth(accounts Accounts) HandlerFunc
var BasicAuthForRealm = gin.BasicAuthForRealm
gin.BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc
var Bind = gin.Bind
gin.Bind(val any) HandlerFunc
var BindingDefault = binding.Default
binding.Default(method, contentType string) Binding
var CustomRecovery = gin.CustomRecovery
gin.CustomRecovery(handle RecoveryFunc) HandlerFunc
var CustomRecoveryWithWriter = gin.CustomRecoveryWithWriter
gin.CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc
var Default = gin.Default
默认 gin gin.Default() *Engine
var DefaultErrorWriter = &gin.DefaultErrorWriter
默认错误写入
var DefaultWriter = &gin.DefaultWriter
默认写入
var Dir = gin.Dir
文件夹 gin.Dir(root string, listDirectory bool) http.FileSystem
var DisableBindValidation = gin.DisableBindValidation
DisableBindValidation closes the default validator. gin.DisableBindValidation()
var DisableConsoleColor = gin.DisableConsoleColor
DisableConsoleColor disables color output in the console. gin.DisableConsoleColor()
var EnableJsonDecoderDisallowUnknownFields = gin.EnableJsonDecoderDisallowUnknownFields
gin.EnableJsonDecoderDisallowUnknownFields()
var EnableJsonDecoderUseNumber = gin.EnableJsonDecoderUseNumber
gin.EnableJsonDecoderUseNumber()
var ErrorLogger = gin.ErrorLogger
ErrorLogger returns a handlerfunc for any error type. gin.ErrorLogger() HandlerFunc
var ErrorLoggerT = gin.ErrorLoggerT
gin.ErrorLoggerT(typ ErrorType) HandlerFunc
var ForceConsoleColor = gin.ForceConsoleColor
gin.ForceConsoleColor()
var IsDebugging = gin.IsDebugging
是否为调试 gin.IsDebugging() bool
var Logger = gin.Logger
gin 默认日志中间件 gin.Logger() HandlerFunc
var LoggerWithConfig = gin.LoggerWithConfig
gin.LoggerWithConfig(conf LoggerConfig) HandlerFunc
var LoggerWithFormatter = gin.LoggerWithFormatter
gin.LoggerWithFormatter(f LogFormatter) HandlerFunc
var LoggerWithWriter = gin.LoggerWithWriter
gin.LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc
var Mode = gin.Mode
Mode returns currently gin mode. gin.Mode() string
var New = gin.New
使用 gin gin.New() *Engine
var Recovery = gin.Recovery
gin 默认回收中间件 gin.Recovery() HandlerFunc
var RecoveryWithWriter = gin.RecoveryWithWriter
gin.RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc
var SetMode = gin.SetMode
设置模式 gin.SetMode(value string)
var WrapF = gin.WrapF
gin.WrapF(f http.HandlerFunc) HandlerFunc
var WrapH = gin.WrapH
gin.WrapH(h http.Handler) HandlerFunc
Functions ¶
Types ¶
type Alias ¶
type Alias struct {
// contains filtered or unexported fields
}
*
- 别名 *
- @create 2021-10-16
- @author deatil
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
*
- 分组 *
- @create 2021-10-16
- @author deatil
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
*
- 中间件 *
- @create 2021-9-15
- @author deatil
func (*Middleware) AliasMiddleware ¶
func (this *Middleware) AliasMiddleware(name string, middleware any) *Middleware
*
- 别名
func (*Middleware) GetGlobalMiddlewareList ¶
func (this *Middleware) GetGlobalMiddlewareList() (middleware []any)
*
- 获取全局中间件列表
func (*Middleware) GetMiddlewareList ¶
func (this *Middleware) GetMiddlewareList(name string) (middleware []any)
*
- 获取中间件列表
func (*Middleware) MiddlewareGroup ¶
func (this *Middleware) MiddlewareGroup(name string, middlewares []any) *Middleware
*
- 中间件分组
func (*Middleware) PrependMiddleware ¶
func (this *Middleware) PrependMiddleware(middleware any) *Middleware
*
- 全局中间前置
func (*Middleware) PrependMiddlewareToGroup ¶
func (this *Middleware) PrependMiddlewareToGroup(name string, middleware any) *Middleware
*
- 中间件分组 - 前置
func (*Middleware) PushMiddleware ¶
func (this *Middleware) PushMiddleware(middleware any) *Middleware
*
- 全局中间后置
func (*Middleware) PushMiddlewareToGroup ¶
func (this *Middleware) PushMiddlewareToGroup(name string, middleware any) *Middleware
*
- 中间件分组 - 后置
func (*Middleware) WithGlobalName ¶
func (this *Middleware) WithGlobalName(globalName string) *Middleware
*
- 全局名称
func (*Middleware) WithMiddlewares ¶
func (this *Middleware) WithMiddlewares(middlewares *Middlewares) *Middleware
*
- 中间件
type Middlewares ¶
type Middlewares struct {
// contains filtered or unexported fields
}
*
- 中间件切片 *
- @create 2021-10-16
- @author deatil
func (*Middlewares) Prepend ¶
func (this *Middlewares) Prepend(middlewares ...any) *Middlewares
*
- 前置添加
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
*
- 缓存路由信息 *
- @create 2021-9-7
- @author deatil
func (*Route) GetRoutes ¶
func (this *Route) GetRoutes() RoutesInfo
路由信息
type RouteInfo struct { Method string Path string Handler string HandlerFunc HandlerFunc }
RoutesInfo []RouteInfo
type RouteName ¶
type RouteName struct {
// contains filtered or unexported fields
}
*
- 别名 *
- @create 2022-3-7
- @author deatil
func (*RouteName) SetRouteName ¶
func (this *RouteName) SetRouteName(name string, route RouterInfo) *RouteName
设置
type RouterInfo ¶
别名信息
type RouteInfo struct { Method string Path string Handler string HandlerFunc HandlerFunc }