router

package
v1.0.1006 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// 模式
	EnvGinMode = gin.EnvGinMode

	// 调试模式
	DebugMode = gin.DebugMode

	// 线上模式
	ReleaseMode = gin.ReleaseMode

	// 测试模式
	TestMode = gin.TestMode
)

Variables

View Source
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
)
View Source
var BasicAuth = gin.BasicAuth

gin.BasicAuth(accounts Accounts) HandlerFunc

View Source
var BasicAuthForRealm = gin.BasicAuthForRealm

gin.BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc

View Source
var Bind = gin.Bind

gin.Bind(val any) HandlerFunc

View Source
var BindingDefault = binding.Default

binding.Default(method, contentType string) Binding

View Source
var CustomRecovery = gin.CustomRecovery

gin.CustomRecovery(handle RecoveryFunc) HandlerFunc

View Source
var CustomRecoveryWithWriter = gin.CustomRecoveryWithWriter

gin.CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc

View Source
var Default = gin.Default

默认 gin gin.Default() *Engine

View Source
var DefaultErrorWriter = &gin.DefaultErrorWriter

默认错误写入

View Source
var DefaultWriter = &gin.DefaultWriter

默认写入

View Source
var Dir = gin.Dir

文件夹 gin.Dir(root string, listDirectory bool) http.FileSystem

View Source
var DisableBindValidation = gin.DisableBindValidation

DisableBindValidation closes the default validator. gin.DisableBindValidation()

View Source
var DisableConsoleColor = gin.DisableConsoleColor

DisableConsoleColor disables color output in the console. gin.DisableConsoleColor()

View Source
var EnableJsonDecoderDisallowUnknownFields = gin.EnableJsonDecoderDisallowUnknownFields

gin.EnableJsonDecoderDisallowUnknownFields()

View Source
var EnableJsonDecoderUseNumber = gin.EnableJsonDecoderUseNumber

gin.EnableJsonDecoderUseNumber()

View Source
var ErrorLogger = gin.ErrorLogger

ErrorLogger returns a handlerfunc for any error type. gin.ErrorLogger() HandlerFunc

View Source
var ErrorLoggerT = gin.ErrorLoggerT

gin.ErrorLoggerT(typ ErrorType) HandlerFunc

View Source
var ForceConsoleColor = gin.ForceConsoleColor

gin.ForceConsoleColor()

View Source
var IsDebugging = gin.IsDebugging

是否为调试 gin.IsDebugging() bool

View Source
var Logger = gin.Logger

gin 默认日志中间件 gin.Logger() HandlerFunc

View Source
var LoggerWithConfig = gin.LoggerWithConfig

gin.LoggerWithConfig(conf LoggerConfig) HandlerFunc

View Source
var LoggerWithFormatter = gin.LoggerWithFormatter

gin.LoggerWithFormatter(f LogFormatter) HandlerFunc

View Source
var LoggerWithWriter = gin.LoggerWithWriter

gin.LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc

View Source
var Mode = gin.Mode

Mode returns currently gin mode. gin.Mode() string

View Source
var New = gin.New

使用 gin gin.New() *Engine

View Source
var Recovery = gin.Recovery

gin 默认回收中间件 gin.Recovery() HandlerFunc

View Source
var RecoveryWithWriter = gin.RecoveryWithWriter

gin.RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc

View Source
var SetMode = gin.SetMode

设置模式 gin.SetMode(value string)

View Source
var WrapF = gin.WrapF

gin.WrapF(f http.HandlerFunc) HandlerFunc

View Source
var WrapH = gin.WrapH

gin.WrapH(h http.Handler) HandlerFunc

Functions

func AliasMiddleware

func AliasMiddleware(name string, middleware any)

*

  • 中间件别名

func FormatURL

func FormatURL(u string) string

func GetHeaderByName

func GetHeaderByName(ctx *Context, key string) string

获取 header 中指定 key 的值

func GetLocalIP

func GetLocalIP() string

获取本地IP

func GetRealIP

func GetRealIP(ctx *Context) (ip string)

获取真实IP

func GetRequestIp

func GetRequestIp(ctx *Context) string

请求 IP

func IntranetIP

func IntranetIP() (ips []string, err error)

获取IP地址列表

func IsIntranetIp

func IsIntranetIp(ipStr string) bool

IP 地址是否正确判断

func MatchPath

func MatchPath(ctx *Context, path string, current string) bool

匹配链接

func MiddlewareGroup

func MiddlewareGroup(name string, middlewares []any)

*

  • 中间件分组

func PushMiddleware added in v1.0.1006

func PushMiddleware(middleware any)

*

  • 添加全局中间件

func WithDefaultErrorWriter

func WithDefaultErrorWriter(writer io.Writer)

设置默认错误写入

func WithDefaultWriter

func WithDefaultWriter(writer io.Writer)

设置默认写入

Types

type Accounts

type Accounts = gin.Accounts

验证

type Alias

type Alias struct {
	// contains filtered or unexported fields
}

*

  • 别名 *
  • @create 2021-10-16
  • @author deatil

func NewAlias

func NewAlias() *Alias

*

  • New

func (*Alias) Get

func (this *Alias) Get(name string) any

*

  • 获取

func (*Alias) GetAll

func (this *Alias) GetAll() map[string]any

*

  • 获取全部

func (*Alias) Remove

func (this *Alias) Remove(name string)

*

  • 移除

func (*Alias) With

func (this *Alias) With(name string, middleware any) *Alias

*

  • 设置中间件

type Binding

type Binding = binding.Binding

Binding

type BindingBody

type BindingBody = binding.BindingBody

BindingBody

type BindingUri

type BindingUri = binding.BindingUri

BindingUri

type Context

type Context = gin.Context

上下文

type Engine

type Engine = gin.Engine

路由

type Error

type Error = gin.Error

错误

type ErrorType

type ErrorType = gin.ErrorType

错误码类型

type Group

type Group struct {
	// contains filtered or unexported fields
}

*

  • 分组 *
  • @create 2021-10-16
  • @author deatil

func NewGroup

func NewGroup() *Group

*

  • New

func (*Group) Exists

func (this *Group) Exists(name string) bool

*

  • 判断

func (*Group) Get

func (this *Group) Get(name string) *Middlewares

*

  • 获取分组

func (*Group) Prepend

func (this *Group) Prepend(name string, middleware any) *Group

*

  • 添加分组 - 前置

func (*Group) Push

func (this *Group) Push(name string, middleware any) *Group

*

  • 添加分组 - 后置

func (*Group) Remove

func (this *Group) Remove(name string)

*

  • 删除

func (*Group) With

func (this *Group) With(name string, middlewares []any) *Group

*

  • 添加分组 - 覆盖

type H

type H = gin.H

gin 输出数据

type HandlerFunc

type HandlerFunc = gin.HandlerFunc

中间件

func GetGlobalMiddlewares

func GetGlobalMiddlewares() (handlerFuncs []HandlerFunc)

*

  • 获取全局中间件列表

func GetMiddlewares

func GetMiddlewares(name string) (handlerFuncs []HandlerFunc)

*

  • 获取中间件列表

type HandlersChain

type HandlersChain = gin.HandlersChain

中间件列表

type IRouter

type IRouter = gin.IRouter

路由接口

func Groups added in v1.0.1006

func Groups(engine IRouter, relativePath string, middlewareName string) IRouter

使用设置的中间件设置分组

type IRoutes

type IRoutes = gin.IRoutes

路由接口列表

func Use added in v1.0.1006

func Use(engine IRoutes, middlewareName string) IRoutes

使用设置的中间件

type LogFormatter

type LogFormatter = gin.LogFormatter

LogFormatter

type LogFormatterParams

type LogFormatterParams = gin.LogFormatterParams

LogFormatterParams

type LoggerConfig

type LoggerConfig = gin.LoggerConfig

LoggerConfig

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

*

  • 中间件 *
  • @create 2021-9-15
  • @author deatil

func InstanceMiddleware

func InstanceMiddleware() *Middleware

*

  • 单例模式

func NewMiddleware

func NewMiddleware() *Middleware

*

  • New

func (*Middleware) AliasMiddleware

func (this *Middleware) AliasMiddleware(name string, middleware any) *Middleware

*

  • 别名

func (*Middleware) GetAlias

func (this *Middleware) GetAlias() *Alias

*

  • 别名

func (*Middleware) GetGlobalMiddlewareList

func (this *Middleware) GetGlobalMiddlewareList() (middleware []any)

*

  • 获取全局中间件列表

func (*Middleware) GetGlobalName

func (this *Middleware) GetGlobalName() string

*

  • 全局名称

func (*Middleware) GetGroup

func (this *Middleware) GetGroup() *Group

*

  • 中间件分组

func (*Middleware) GetMiddlewareList

func (this *Middleware) GetMiddlewareList(name string) (middleware []any)

*

  • 获取中间件列表

func (*Middleware) GetMiddlewares

func (this *Middleware) GetMiddlewares() *Middlewares

*

  • 中间件

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) WithAlias

func (this *Middleware) WithAlias(alias *Alias) *Middleware

*

  • 别名

func (*Middleware) WithGlobalName

func (this *Middleware) WithGlobalName(globalName string) *Middleware

*

  • 全局名称

func (*Middleware) WithGroup

func (this *Middleware) WithGroup(group *Group) *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 NewMiddlewares

func NewMiddlewares() *Middlewares

*

  • New

func (*Middlewares) All

func (this *Middlewares) All() []any

*

  • 全部

func (*Middlewares) Prepend

func (this *Middlewares) Prepend(middlewares ...any) *Middlewares

*

  • 前置添加

func (*Middlewares) Push

func (this *Middlewares) Push(middlewares ...any) *Middlewares

*

  • 后置添加

func (*Middlewares) Remove

func (this *Middlewares) Remove(middleware any) bool

*

  • 移除

func (*Middlewares) With

func (this *Middlewares) With(middlewares []any) *Middlewares

*

  • 覆写

type Negotiate

type Negotiate = gin.Negotiate

Negotiate

type Param

type Param = gin.Param

请求数据

type Params

type Params = gin.Params

请求数据列表

type RecoveryFunc

type RecoveryFunc = gin.RecoveryFunc

RecoveryFunc

type Render

type Render = render.Render

Render

type ResponseWriter

type ResponseWriter = gin.ResponseWriter

响应

type Route

type Route struct {
	// contains filtered or unexported fields
}

*

  • 缓存路由信息 *
  • @create 2021-9-7
  • @author deatil

func NewRoute

func NewRoute() *Route

func (*Route) Get

func (this *Route) Get() *Engine

设置

func (*Route) GetLastRoute

func (this *Route) GetLastRoute() RouteInfo

最后一个

func (*Route) GetRouteMap

func (this *Route) GetRouteMap() map[string]any

路由信息

func (*Route) GetRoutes

func (this *Route) GetRoutes() RoutesInfo

路由信息

type RouteInfo struct {
    Method      string
    Path        string
    Handler     string
    HandlerFunc HandlerFunc
}

RoutesInfo []RouteInfo

func (*Route) With

func (this *Route) With(engine *Engine)

设置

type RouteInfo

type RouteInfo = gin.RouteInfo

路由信息

type RouteName

type RouteName struct {
	// contains filtered or unexported fields
}

*

  • 别名 *
  • @create 2022-3-7
  • @author deatil

func Name

func Name(name string) *RouteName

单例

func NewName

func NewName() *RouteName

单例

func (*RouteName) GetRoute

func (this *RouteName) GetRoute(name string) RouterInfo

获取单个

func (*RouteName) GetRoutes

func (this *RouteName) GetRoutes() RouterInfoMap

获取全部

func (*RouteName) SetName

func (this *RouteName) SetName(name string) *RouteName

设置别名

func (*RouteName) SetRouteName

func (this *RouteName) SetRouteName(name string, route RouterInfo) *RouteName

设置

type RouterGroup

type RouterGroup = gin.RouterGroup

路由分组

type RouterInfo

type RouterInfo struct {
	// 默认
	RouteInfo

	// 别名
	Name string
}

别名信息

type RouteInfo struct {
    Method      string
    Path        string
    Handler     string
    HandlerFunc HandlerFunc
}

type RouterInfoMap

type RouterInfoMap = map[string]RouterInfo

map 列表

type RoutesInfo

type RoutesInfo = gin.RoutesInfo

路由信息列表

type StructValidator

type StructValidator = binding.StructValidator

StructValidator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL