kid

package module
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 21 Imported by: 0

README

kid

Documentation

Index

Constants

View Source

Variables

View Source
var Validator = validator.New()

Functions

func PrintLogo()

func Struct added in v0.0.4

func Struct(value interface{}) error

func Verify added in v0.0.4

func Verify(ctx *Context, rules Rules) (err error)

Types

type Context

type Context struct {
	*gin.Context
	Guard guard.Guard `inject:""`
}

func (*Context) FindDefaultFloat32 added in v0.0.4

func (ctx *Context) FindDefaultFloat32(key string, defaultValue float32) float32

func (*Context) FindDefaultFloat64 added in v0.0.4

func (ctx *Context) FindDefaultFloat64(key string, defaultValue float64) float64

func (*Context) FindDefaultInt added in v0.0.4

func (ctx *Context) FindDefaultInt(key string, defaultValue int) int

func (*Context) FindDefaultInt64 added in v0.0.4

func (ctx *Context) FindDefaultInt64(key string, defaultValue int64) int64

func (*Context) FindDefaultString added in v0.0.4

func (ctx *Context) FindDefaultString(key, defaultValue string) string

func (*Context) FindFloat32 added in v0.0.4

func (ctx *Context) FindFloat32(key string) float32

func (*Context) FindFloat64 added in v0.0.4

func (ctx *Context) FindFloat64(key string) float64

func (*Context) FindInt added in v0.0.4

func (ctx *Context) FindInt(key string) int

func (*Context) FindInt64 added in v0.0.4

func (ctx *Context) FindInt64(key string) int64

func (*Context) FindString added in v0.0.4

func (ctx *Context) FindString(key string) string

func (*Context) GetValue added in v0.0.4

func (ctx *Context) GetValue(key string, recipient interface{}) error

func (*Context) Valid added in v0.0.4

func (ctx *Context) Valid(recipient interface{}) error

func (*Context) ValidFiled added in v0.0.4

func (ctx *Context) ValidFiled(rules Rules) error

type HandleFunc

type HandleFunc func(*Context) interface{}

type Kid

type Kid struct {
	*gin.Engine
	RouterGroup
	Logger logger.Logger

	Options *Options
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Kid

func Registry added in v0.0.4

func Registry(plugin plugin.Plugin, opts ...container.Option) *Kid

func (*Kid) AutoMigrate added in v0.0.4

func (kid *Kid) AutoMigrate()

AutoMigrate 自动迁移数据库

func (*Kid) CommandLine added in v0.0.4

func (kid *Kid) CommandLine() error

CommandLine 命令行处理

func (*Kid) Get added in v0.0.4

func (kid *Kid) Get(plugin plugin.Plugin, name ...string) (interface{}, error)

func (*Kid) Init added in v0.0.4

func (kid *Kid) Init() error

func (*Kid) Launch

func (kid *Kid) Launch(hosts ...string)

func (*Kid) NewDbCommand added in v0.0.4

func (kid *Kid) NewDbCommand() *cobra.Command

NewDbCommand 数据库相关命令

func (*Kid) NewHelpCommand added in v0.0.4

func (kid *Kid) NewHelpCommand() *cobra.Command

func (*Kid) NewServerCommand added in v0.0.4

func (kid *Kid) NewServerCommand() *cobra.Command

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) Populate added in v0.0.4

func (kid *Kid) Populate() error

func (*Kid) Registry

func (kid *Kid) Registry(plugin plugin.Plugin, opts ...container.Option) *Kid

Registry 将插件注入容器

type LogFormatter added in v0.0.4

type LogFormatter func(params LogFormatterParams) string

type LogFormatterParams added in v0.0.4

type LogFormatterParams struct {
	Request      *http.Request
	TimeStamp    time.Time
	StatusCode   int
	Latency      time.Duration
	ClientIP     string
	Method       string
	Path         string
	ErrorMessage string

	BodySize int
	Keys     map[string]interface{}
	// contains filtered or unexported fields
}

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 WithAppName(name string) Option

func WithConfigs added in v0.0.4

func WithConfigs(configs ...string) Option

func WithDbMigrate added in v0.0.4

func WithDbMigrate(migrate mysql.AutoMigrate) Option

func WithRunMode added in v0.0.4

func WithRunMode(runMode string) Option

type Options added in v0.0.4

type Options struct {
	Name            string
	AutoMigrate     bool
	Configs         []string
	RunMode         string
	DatabaseMigrate mysql.AutoMigrate
}

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)

type Rules added in v0.0.4

type Rules map[string]interface{}

Jump to

Keyboard shortcuts

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