Documentation
¶
Index ¶
- Constants
- Variables
- func NewValidator() *validator.Validate
- func PrintLogo()
- func Struct(value interface{}) error
- func Verify(ctx *Context, rules Rules) error
- type Context
- func (ctx *Context) BindUser(val interface{})
- func (ctx *Context) FindBool(key string) bool
- func (ctx *Context) FindDefaultBool(key string, defaultValue bool) bool
- func (ctx *Context) FindDefaultFloat32(key string, defaultValue float32) float32
- func (ctx *Context) FindDefaultFloat64(key string, defaultValue float64) float64
- func (ctx *Context) FindDefaultInt(key string, defaultValue int) int
- func (ctx *Context) FindDefaultInt64(key string, defaultValue int64) int64
- func (ctx *Context) FindDefaultInt8(key string, defaultVal int8) int8
- func (ctx *Context) FindDefaultString(key, defaultValue string) string
- func (ctx *Context) FindDefaultUint8(key string, defaultVal uint8) uint8
- func (ctx *Context) FindFloat32(key string) float32
- func (ctx *Context) FindFloat64(key string) float64
- func (ctx *Context) FindInt(key string) int
- func (ctx *Context) FindInt64(key string) int64
- func (ctx *Context) FindInt8(key string) int8
- func (ctx *Context) FindString(key string) string
- func (ctx *Context) FindUint8(key string) uint8
- func (ctx *Context) GetBindUser(recipient interface{}) error
- func (ctx *Context) GetResponseType() ResponseType
- func (ctx *Context) GetValue(key string, recipient interface{}) error
- func (ctx *Context) SetResponseType(respType ResponseType)
- func (ctx *Context) Valid(recipient interface{}) error
- func (ctx *Context) ValidFiled(rules Rules) error
- type HandleFunc
- type Kid
- func (kid *Kid) AutoMigrate(closeFKCheck bool)
- func (kid *Kid) CommandLine() error
- func (kid *Kid) Init() error
- func (kid *Kid) Launch(hosts ...string)
- func (kid *Kid) NewDbCommand() *cobra.Command
- func (kid *Kid) NewHelpCommand() *cobra.Command
- func (kid *Kid) NewServerCommand() *cobra.Command
- func (kid *Kid) NoMethod(handleFunc HandleFunc)
- func (kid *Kid) NoRoute(handleFunc HandleFunc)
- func (kid *Kid) Populate() error
- func (kid *Kid) Registry(plugin plugin.Plugin, opts ...injector.Option) *Kid
- type LogFormatter
- type LogFormatterParams
- type LoggerConfig
- type Middleware
- type Option
- type Options
- type ResponseType
- type RouterGroup
- func (group *RouterGroup) DELETE(path string, handler HandleFunc, middlewares ...Middleware)
- func (group *RouterGroup) GET(path string, handler HandleFunc, middlewares ...Middleware)
- func (group *RouterGroup) Group(path string, middlewares ...Middleware) *RouterGroup
- func (group *RouterGroup) POST(path string, handler HandleFunc, middlewares ...Middleware)
- func (group *RouterGroup) PUT(path string, handler HandleFunc, middlewares ...Middleware)
- func (group *RouterGroup) UseMiddle(middlewares ...Middleware)
- type Rules
Constants ¶
View Source
const ( ResponseTypeJson = iota + 1 // 1 json 类型 ResponseTypeXml // 2 xml 类型 ResponseTypeYaml // 3 yaml 类型 ResponseTypeHtml // 4 html 类型 ResponseTypeIndentedJson // 5 格式化 json ResponseTypeSecureJson // 6 安全的 json ResponseTypeJsonP // 7 返回 jsonp 格式 ResponseTypeAsciiJson // 8 返回 Ascii 码的 json 会将 Unicode 转换为 ASCII ResponseTypePureJson // 9 pure json 格式化 ResponseTypeToml // 10 分会 toml 格式 ResponseTypeProtoBuf // 11 以 protobuf 格式输出 ResponseTypeString // 12 以字符串格式输出 ResponseTypeRedirect // 13 重定向 ResponseTypeFile // 14 文件 ResponseTypeFileFromFS // 15 远程文件系统 ResponseTypeFileAttachment // 16 FileAttachment ResponseTypeSSEvent // 17 SSEvent ResponseTypeStream // 18 数据流 )
View Source
const CommandLogo = `` /* 402-byte string literal not displayed */
View Source
const (
ResponseTypeKey = "resp_type"
)
View Source
const UserBindKey = "bind_user"
Variables ¶
View Source
var Validator = NewValidator()
Functions ¶
func NewValidator ¶
Types ¶
type Context ¶
func (*Context) FindDefaultBool ¶
func (*Context) FindDefaultFloat32 ¶
func (*Context) FindDefaultFloat64 ¶
func (*Context) FindDefaultInt ¶
func (*Context) FindDefaultInt64 ¶
func (*Context) FindDefaultInt8 ¶
func (*Context) FindDefaultString ¶
func (*Context) FindDefaultUint8 ¶
func (*Context) FindFloat32 ¶
func (*Context) FindFloat64 ¶
func (*Context) FindString ¶
func (*Context) GetBindUser ¶
GetBindUser 获取绑定的用户
func (*Context) GetResponseType ¶
func (ctx *Context) GetResponseType() ResponseType
GetResponseType 获取响应格式化类型
func (*Context) SetResponseType ¶
func (ctx *Context) SetResponseType(respType ResponseType)
SetResponseType 指定响应格式类型
func (*Context) ValidFiled ¶
type HandleFunc ¶
func WrapHandler ¶
func WrapHandler(handler gin.HandlerFunc) HandleFunc
type Kid ¶
type Kid struct {
*gin.Engine
RouterGroup
Logger logger.Logger
IocContainer *injector.Container
Options *Options
// contains filtered or unexported fields
}
func (*Kid) NewHelpCommand ¶
func (*Kid) NewServerCommand ¶
NewServerCommand 服务启动相关命令
func (*Kid) NoMethod ¶
func (kid *Kid) NoMethod(handleFunc HandleFunc)
func (*Kid) NoRoute ¶
func (kid *Kid) NoRoute(handleFunc HandleFunc)
type LogFormatter ¶
type LogFormatter func(params LogFormatterParams) string
type LogFormatterParams ¶
type LoggerConfig ¶
type LoggerConfig struct {
Formatter LogFormatter
Output io.Writer
SkipPaths []string
}
type Middleware ¶
type Middleware func(*Context)
func LoggerWithConfig ¶
func LoggerWithConfig(conf LoggerConfig) Middleware
func LoggerWithFormatter ¶
func LoggerWithFormatter(f LogFormatter) Middleware
type Option ¶
type Option func(*Options)
func WithAppName ¶
func WithConfigs ¶
func WithDbMigrate ¶
func WithDbMigrate(migrate mysql.AutoMigrate) Option
func WithRunMode ¶
type ResponseType ¶
type ResponseType int8
type RouterGroup ¶
type RouterGroup struct {
*gin.RouterGroup
}
func (*RouterGroup) DELETE ¶
func (group *RouterGroup) DELETE(path string, handler HandleFunc, middlewares ...Middleware)
func (*RouterGroup) GET ¶
func (group *RouterGroup) GET(path string, handler HandleFunc, middlewares ...Middleware)
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(path string, middlewares ...Middleware) *RouterGroup
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(path string, handler HandleFunc, middlewares ...Middleware)
func (*RouterGroup) PUT ¶
func (group *RouterGroup) PUT(path string, handler HandleFunc, middlewares ...Middleware)
func (*RouterGroup) UseMiddle ¶
func (group *RouterGroup) UseMiddle(middlewares ...Middleware)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.