Documentation
¶
Overview ¶
Package cherryGin from https://github.com/gin-contrib/zap/
Index ¶
- func BindHandler(handler func(ctx *Context)) gin.HandlerFunc
- func BindHandlers(handlers []GinHandlerFunc) []gin.HandlerFunc
- func SetMode(value string)
- type BaseController
- func (b *BaseController) Any(relativePath string, handlers ...GinHandlerFunc)
- func (b *BaseController) GET(relativePath string, handlers ...GinHandlerFunc)
- func (b *BaseController) Group(relativePath string, handlers ...GinHandlerFunc) *Group
- func (b *BaseController) Init()
- func (b *BaseController) POST(relativePath string, handlers ...GinHandlerFunc)
- func (b *BaseController) PreInit(app cfacade.IApplication, engine *gin.Engine)
- func (b *BaseController) Stop()
- type Component
- type Context
- func (g *Context) GetBody() string
- func (g *Context) GetBool(name string, defaultValue bool, checkPost ...bool) bool
- func (g *Context) GetInt(name string, defaultValue int, checkPost ...bool) int
- func (g *Context) GetInt32(name string, defaultValue int32, checkPost ...bool) int32
- func (g *Context) GetInt64(name string, defaultValue int64, checkPost ...bool) int64
- func (g *Context) GetParams(checkPost ...bool) map[string]string
- func (g *Context) GetString(name, defaultValue string, checkPost ...bool) string
- func (g *Context) HTML200(name string, obj ...interface{})
- func (g *Context) IsGet() bool
- func (g *Context) IsPost() bool
- func (g *Context) JSON200(obj interface{})
- func (g *Context) PostFormInt32Array(name string) []int32
- func (g *Context) PostFormInt64Array(name string) []int64
- func (g *Context) PostFormIntArray(name string) []int
- func (g *Context) PostInt(name string, defaultValue int) int
- func (g *Context) PostInt64(name string, defaultValue int64) int64
- func (g *Context) PostString(name string, defaultValue string) string
- func (g *Context) RenderHTML(html string)
- func (g *Context) RenderJSON(value interface{})
- func (g *Context) RenderJsonString(json string)
- type GinHandlerFunc
- type Group
- type HttpServer
- func (p *HttpServer) Register(controllers ...IController) *HttpServer
- func (p *HttpServer) Run()
- func (p *HttpServer) SetIApplication(app cfacade.IApplication)
- func (p *HttpServer) Static(relativePath string, staticDir string)
- func (p *HttpServer) StaticFile(relativePath, filepath string)
- func (p *HttpServer) Stop()
- func (p *HttpServer) Use(middleware ...GinHandlerFunc)
- type IController
- type OptionFunc
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindHandler ¶ added in v1.1.22
func BindHandler(handler func(ctx *Context)) gin.HandlerFunc
func BindHandlers ¶ added in v1.1.22
func BindHandlers(handlers []GinHandlerFunc) []gin.HandlerFunc
Types ¶
type BaseController ¶ added in v1.1.0
type BaseController struct {
App cfacade.IApplication
Engine *gin.Engine
}
func (*BaseController) Any ¶ added in v1.1.0
func (b *BaseController) Any(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) GET ¶ added in v1.1.0
func (b *BaseController) GET(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) Group ¶ added in v1.1.22
func (b *BaseController) Group(relativePath string, handlers ...GinHandlerFunc) *Group
func (*BaseController) Init ¶ added in v1.1.0
func (b *BaseController) Init()
func (*BaseController) POST ¶ added in v1.1.0
func (b *BaseController) POST(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) PreInit ¶ added in v1.1.0
func (b *BaseController) PreInit(app cfacade.IApplication, engine *gin.Engine)
func (*BaseController) Stop ¶ added in v1.1.0
func (b *BaseController) Stop()
type Component ¶ added in v1.1.0
type Component struct {
cfacade.Component
*HttpServer
// contains filtered or unexported fields
}
Component wrapper gin
func (*Component) OnAfterInit ¶ added in v1.1.0
func (g *Component) OnAfterInit()
func (*Component) OnBeforeStop ¶ added in v1.1.0
func (g *Component) OnBeforeStop()
func (*Component) Register ¶ added in v1.1.0
func (g *Component) Register(controllers ...IController) *Component
type Context ¶ added in v1.1.0
func (*Context) PostFormInt32Array ¶ added in v1.1.29
func (*Context) PostFormInt64Array ¶ added in v1.1.29
func (*Context) PostFormIntArray ¶ added in v1.1.29
func (*Context) PostString ¶ added in v1.1.0
func (*Context) RenderHTML ¶ added in v1.1.0
func (*Context) RenderJSON ¶ added in v1.1.0
func (g *Context) RenderJSON(value interface{})
func (*Context) RenderJsonString ¶ added in v1.1.21
type GinHandlerFunc ¶ added in v1.1.22
type GinHandlerFunc func(ctx *Context)
func Cors ¶ added in v1.1.11
func Cors(domain ...string) GinHandlerFunc
func GinDefaultZap ¶
func GinDefaultZap() GinHandlerFunc
func GinZap ¶
func GinZap(timeFormat string, utc bool) GinHandlerFunc
GinZap returns a gin.HandlerFunc (middleware) that logs requests using uber-go/zap.
Requests with errors are logged using zap.Error(). Requests without errors are logged using zap.Info().
It receives:
- A time package format string (e.g. time.RFC3339).
- A boolean stating whether to use UTC time zone or local.
func MaxConnect ¶ added in v1.1.22
func MaxConnect(n int) GinHandlerFunc
MaxConnect limit max connect
func RecoveryWithZap ¶
func RecoveryWithZap(stack bool) GinHandlerFunc
RecoveryWithZap returns a gin.HandlerFunc (middleware) that recovers from any panics and logs requests using uber-go/zap. All errors are logged using zap.Error(). stack means whether output the stack info. The stack info is easy to find where the error occurs but the stack info is too large.
type Group ¶ added in v1.1.22
type Group struct {
*gin.RouterGroup
}
func (*Group) Any ¶ added in v1.1.22
func (p *Group) Any(relativePath string, handlers ...GinHandlerFunc)
func (*Group) GET ¶ added in v1.1.22
func (p *Group) GET(relativePath string, handlers ...GinHandlerFunc)
func (*Group) POST ¶ added in v1.1.22
func (p *Group) POST(relativePath string, handlers ...GinHandlerFunc)
type HttpServer ¶ added in v1.1.22
type HttpServer struct {
cfacade.IApplication
Options
*gin.Engine
// contains filtered or unexported fields
}
func NewHttpServer ¶ added in v1.1.22
func NewHttpServer(address string, opts ...OptionFunc) *HttpServer
func (*HttpServer) Register ¶ added in v1.1.22
func (p *HttpServer) Register(controllers ...IController) *HttpServer
func (*HttpServer) Run ¶ added in v1.1.22
func (p *HttpServer) Run()
func (*HttpServer) SetIApplication ¶ added in v1.1.22
func (p *HttpServer) SetIApplication(app cfacade.IApplication)
func (*HttpServer) Static ¶ added in v1.1.22
func (p *HttpServer) Static(relativePath string, staticDir string)
func (*HttpServer) StaticFile ¶ added in v1.1.22
func (p *HttpServer) StaticFile(relativePath, filepath string)
func (*HttpServer) Stop ¶ added in v1.1.22
func (p *HttpServer) Stop()
func (*HttpServer) Use ¶ added in v1.1.22
func (p *HttpServer) Use(middleware ...GinHandlerFunc)
type IController ¶
type IController interface {
PreInit(app cfacade.IApplication, engine *gin.Engine)
Init()
Stop()
}
type OptionFunc ¶ added in v1.1.22
type OptionFunc func(opts *Options)
func WithCert ¶ added in v1.1.22
func WithCert(certFile, keyFile string) OptionFunc
func WithIdleTimeout ¶ added in v1.1.22
func WithIdleTimeout(t time.Duration) OptionFunc
func WithMaxHeaderBytes ¶ added in v1.1.22
func WithMaxHeaderBytes(val int) OptionFunc
func WithReadHeaderTimeout ¶ added in v1.1.22
func WithReadHeaderTimeout(t time.Duration) OptionFunc
func WithReadTimeout ¶ added in v1.1.22
func WithReadTimeout(t time.Duration) OptionFunc
Click to show internal directories.
Click to hide internal directories.