Documentation ¶
Index ¶
- Constants
- Variables
- func BindPairs(ctx *gin.Context, pairs ...BindPair) error
- func MetaHandler(meta Meta) gin.HandlerFunc
- func SetMode(mode GinMode)
- type BindPair
- type Coco
- func (c *Coco) AddInterruptFn(fn ...InterruptFn)
- func (c *Coco) AddPostAsyncCs(cs ...ComponentFn)
- func (c *Coco) AddPreAsyncCs(cs ...ComponentFn)
- func (c *Coco) AddPreSyncCs(cs ...ComponentFn)
- func (c *Coco) Core() Core
- func (c *Coco) Run() error
- func (c *Coco) RunListener(l net.Listener) error
- func (c *Coco) RunListenerTls(l net.Listener, certFile, keyFile string) error
- func (c *Coco) RunTLS(certFile, keyFile string) error
- func (c *Coco) SetSignals(s ...os.Signal)
- type ComponentFn
- func WithConfig(cfg *Config) ComponentFn
- func WithCtx(ctx context.Context) ComponentFn
- func WithEngine(e *gin.Engine) ComponentFn
- func WithLogger(logger *logrus.Logger) ComponentFn
- func WithMiddleware(opts ...MiddlewareOpt) ComponentFn
- func WithServer(server *http.Server) ComponentFn
- func WithValidator(vFn ValidateComp) ComponentFn
- type Config
- type Core
- type GinMode
- type InterruptFn
- type Meta
- type MiddlewareOpt
- type Router
- func (w *Router) Any(path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo
- func (w *Router) DELETE(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) GET(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) Group(path string, meta Meta, handler ...gin.HandlerFunc) RouterGroup
- func (w *Router) HEAD(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) Handle(method, path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) Match(method []string, path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo
- func (w *Router) OPTIONS(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) PATCH(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) POST(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) PUT(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
- func (w *Router) Use(handler ...gin.HandlerFunc)
- func (w *Router) Walk(walker Walker) error
- type RouterGroup
- type RouterInfo
- type Routes
- type ValidateComp
- type Validator
- type Walker
Constants ¶
View Source
const ( ReleaseMode GinMode = "release" DebugMode = "debug" Test = "test" )
Variables ¶
View Source
var MetaKey = "meta"
MetaKey meta key, could update if you need
Functions ¶
func MetaHandler ¶ added in v1.0.12
func MetaHandler(meta Meta) gin.HandlerFunc
Types ¶
type Coco ¶
type Coco struct {
// contains filtered or unexported fields
}
Coco coco http server
func New ¶ added in v1.0.4
func New(opts ...ComponentFn) *Coco
New create new coco with options param opts ...ComponentFn return *Coco
func NewWithCore ¶ added in v1.0.4
NewWithCore param Core *Core return *Coco with custom Core
func (*Coco) AddInterruptFn ¶
func (c *Coco) AddInterruptFn(fn ...InterruptFn)
func (*Coco) AddPostAsyncCs ¶
func (c *Coco) AddPostAsyncCs(cs ...ComponentFn)
func (*Coco) AddPreAsyncCs ¶
func (c *Coco) AddPreAsyncCs(cs ...ComponentFn)
func (*Coco) AddPreSyncCs ¶
func (c *Coco) AddPreSyncCs(cs ...ComponentFn)
func (*Coco) RunListenerTls ¶ added in v1.0.4
func (*Coco) SetSignals ¶
type ComponentFn ¶
type ComponentFn func(coco *Core)
func WithConfig ¶ added in v1.0.4
func WithConfig(cfg *Config) ComponentFn
func WithCtx ¶ added in v1.0.4
func WithCtx(ctx context.Context) ComponentFn
func WithEngine ¶ added in v1.0.10
func WithEngine(e *gin.Engine) ComponentFn
func WithLogger ¶ added in v1.0.4
func WithLogger(logger *logrus.Logger) ComponentFn
func WithMiddleware ¶ added in v1.0.4
func WithMiddleware(opts ...MiddlewareOpt) ComponentFn
func WithServer ¶ added in v1.0.4
func WithServer(server *http.Server) ComponentFn
func WithValidator ¶ added in v1.0.4
func WithValidator(vFn ValidateComp) ComponentFn
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func DefaultConfig ¶
func DefaultConfig() *Config
func NewConfigFile ¶ added in v1.0.4
func NewConfigReader ¶ added in v1.0.4
func (*Config) ReadConfig ¶
func (*Config) SetCfgType ¶ added in v1.0.4
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core coco Core of http server
type InterruptFn ¶
func ShutdownWithCloseHttp ¶
func ShutdownWithCloseHttp() InterruptFn
func ShutdownWithInfo ¶
func ShutdownWithInfo() InterruptFn
type MiddlewareOpt ¶ added in v1.0.4
type MiddlewareOpt = func(coco *Core) gin.HandlerFunc
type Router ¶ added in v1.0.12
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Any ¶ added in v1.0.12
func (w *Router) Any(path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo
func (*Router) DELETE ¶ added in v1.0.12
func (w *Router) DELETE(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) GET ¶ added in v1.0.12
func (w *Router) GET(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) Group ¶ added in v1.0.12
func (w *Router) Group(path string, meta Meta, handler ...gin.HandlerFunc) RouterGroup
func (*Router) HEAD ¶ added in v1.0.12
func (w *Router) HEAD(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) Handle ¶ added in v1.0.12
func (w *Router) Handle(method, path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) Match ¶ added in v1.0.12
func (w *Router) Match(method []string, path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo
func (*Router) OPTIONS ¶ added in v1.0.12
func (w *Router) OPTIONS(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) PATCH ¶ added in v1.0.12
func (w *Router) PATCH(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) POST ¶ added in v1.0.12
func (w *Router) POST(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) PUT ¶ added in v1.0.12
func (w *Router) PUT(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo
func (*Router) Use ¶ added in v1.0.13
func (w *Router) Use(handler ...gin.HandlerFunc)
type RouterGroup ¶ added in v1.0.12
type RouterGroup interface { Use(handler ...gin.HandlerFunc) Group(path string, meta Meta, handler ...gin.HandlerFunc) RouterGroup Handle(method, path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo GET(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo POST(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo DELETE(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo PUT(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo HEAD(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo OPTIONS(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo PATCH(path string, meta Meta, handler ...gin.HandlerFunc) RouterInfo Any(path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo Match(method []string, path string, meta Meta, handler ...gin.HandlerFunc) []RouterInfo }
type RouterInfo ¶ added in v1.0.12
type RouterInfo struct { IsGroup bool Group *gin.RouterGroup Method string FullPath string Meta Meta Chain gin.HandlersChain }
RouterInfo describe a registered info if IsGroup is true, the root represent itself
type Routes ¶ added in v1.0.12
type Routes struct {
// contains filtered or unexported fields
}
Routes which store all registered route info
func (*Routes) AddRoute ¶ added in v1.0.12
func (r *Routes) AddRoute(info RouterInfo)
type ValidateComp ¶ added in v1.0.4
type ValidateComp func(core *Core) binding.StructValidator
type Walker ¶ added in v1.0.12
type Walker func(info RouterInfo) error
Click to show internal directories.
Click to hide internal directories.