Documentation ¶
Index ¶
- Constants
- Variables
- func PrintLogo()
- func Struct(value interface{}) error
- func Verify(ctx *Context, rules Rules) (err 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()
- func (kid *Kid) CommandLine() error
- func (kid *Kid) Get(plugin plugin.Plugin, name ...string) (interface{}, 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) PopulateOne(plugin plugin.Plugin, opts ...container.Option) error
- func (kid *Kid) Registry(plugin plugin.Plugin, opts ...container.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 = validator.New()
Functions ¶
Types ¶
type Context ¶
func (*Context) BindUser ¶ added in v0.0.4
func (ctx *Context) BindUser(val interface{})
BindUser 绑定用户
func (*Context) FindDefaultBool ¶ added in v0.0.4
func (*Context) FindDefaultFloat32 ¶ added in v0.0.4
func (*Context) FindDefaultFloat64 ¶ added in v0.0.4
func (*Context) FindDefaultInt ¶ added in v0.0.4
func (*Context) FindDefaultInt64 ¶ added in v0.0.4
func (*Context) FindDefaultInt8 ¶ added in v0.0.4
func (*Context) FindDefaultString ¶ added in v0.0.4
func (*Context) FindDefaultUint8 ¶ added in v0.0.4
func (*Context) FindFloat32 ¶ added in v0.0.4
func (*Context) FindFloat64 ¶ added in v0.0.4
func (*Context) FindString ¶ added in v0.0.4
func (*Context) GetBindUser ¶ added in v0.0.4
GetBindUser 获取绑定的用户
func (*Context) GetResponseType ¶ added in v0.0.4
func (ctx *Context) GetResponseType() ResponseType
GetResponseType 获取响应格式化类型
func (*Context) SetResponseType ¶ added in v0.0.4
func (ctx *Context) SetResponseType(respType ResponseType)
SetResponseType 指定响应格式类型
func (*Context) ValidFiled ¶ added in v0.0.4
type HandleFunc ¶
type HandleFunc func(*Context) interface{}
type Kid ¶
type Kid struct { *gin.Engine RouterGroup Logger logger.Logger IocContainer *container.Container Options *Options // contains filtered or unexported fields }
func (*Kid) NewDbCommand ¶ added in v0.0.4
NewDbCommand 数据库相关命令
func (*Kid) NewHelpCommand ¶ added in v0.0.4
func (*Kid) NewServerCommand ¶ added in v0.0.4
NewServerCommand 服务启动相关命令
func (*Kid) NoMethod ¶ added in v0.0.4
func (kid *Kid) NoMethod(handleFunc HandleFunc)
func (*Kid) NoRoute ¶ added in v0.0.4
func (kid *Kid) NoRoute(handleFunc HandleFunc)
func (*Kid) PopulateOne ¶ added in v0.0.4
type LogFormatter ¶ added in v0.0.4
type LogFormatter func(params LogFormatterParams) string
type LogFormatterParams ¶ added in v0.0.4
type LoggerConfig ¶ added in v0.0.4
type LoggerConfig struct { Formatter LogFormatter Output io.Writer SkipPaths []string }
type Middleware ¶ added in v0.0.4
type Middleware func(*Context)
func LoggerWithConfig ¶ added in v0.0.4
func LoggerWithConfig(conf LoggerConfig) Middleware
func LoggerWithFormatter ¶ added in v0.0.4
func LoggerWithFormatter(f LogFormatter) Middleware
type Option ¶ added in v0.0.4
type Option func(*Options)
func WithAppName ¶ added in v0.0.4
func WithConfigs ¶ added in v0.0.4
func WithDbMigrate ¶ added in v0.0.4
func WithDbMigrate(migrate mysql.AutoMigrate) Option
func WithRunMode ¶ added in v0.0.4
type ResponseType ¶ added in v0.0.4
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 ¶ added in v0.0.4
func (group *RouterGroup) UseMiddle(middlewares ...Middleware)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.