Documentation
¶
Overview ¶
Package cherryGin from https://github.com/gin-contrib/zap/
Index ¶
- func Cors(domain ...string) gin.HandlerFunc
- func GinDefaultZap() gin.HandlerFunc
- func GinZap(timeFormat string, utc bool) gin.HandlerFunc
- func RecoveryWithZap(stack bool) gin.HandlerFunc
- type BaseController
- func (b *BaseController) Any(relativePath string, handlers ...HandlerFunc)
- func (b *BaseController) BindHandle(handler func(ctx *Context)) gin.HandlerFunc
- func (b *BaseController) GET(relativePath string, handlers ...HandlerFunc)
- func (b *BaseController) Init()
- func (b *BaseController) POST(relativePath string, handlers ...HandlerFunc)
- func (b *BaseController) PreInit(app cherryFacade.IApplication, engine *gin.Engine)
- func (b *BaseController) Stop()
- type Component
- func New(address string, middleware ...gin.HandlerFunc) *Component
- func NewHttp(name, address string, middleware ...gin.HandlerFunc) *Component
- func NewHttps(name, address, certFile, keyFile string, middleware ...gin.HandlerFunc) *Component
- func NewWithOptions(name string, options Options) *Component
- func (g *Component) Init()
- func (g *Component) Name() string
- func (g *Component) OnAfterInit()
- func (g *Component) OnBeforeStop()
- func (g *Component) OnStop()
- func (g *Component) Register(controllers ...IController) *Component
- func (g *Component) StaticFS(relativePath string, staticDir string)
- func (g *Component) StaticFile(relativePath string, staticDir string)
- 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) 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) RenderResult(code int32, data ...interface{})
- type HandlerFunc
- type IController
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cors ¶ added in v1.1.11
func Cors(domain ...string) gin.HandlerFunc
func GinDefaultZap ¶
func GinDefaultZap() gin.HandlerFunc
func GinZap ¶
func GinZap(timeFormat string, utc bool) gin.HandlerFunc
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 RecoveryWithZap ¶
func RecoveryWithZap(stack bool) gin.HandlerFunc
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.
Types ¶
type BaseController ¶ added in v1.1.0
func (*BaseController) Any ¶ added in v1.1.0
func (b *BaseController) Any(relativePath string, handlers ...HandlerFunc)
func (*BaseController) BindHandle ¶ added in v1.1.0
func (b *BaseController) BindHandle(handler func(ctx *Context)) gin.HandlerFunc
func (*BaseController) GET ¶ added in v1.1.0
func (b *BaseController) GET(relativePath string, handlers ...HandlerFunc)
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 ...HandlerFunc)
func (*BaseController) PreInit ¶ added in v1.1.0
func (b *BaseController) PreInit(app cherryFacade.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 {
cherryFacade.Component
*gin.Engine
// contains filtered or unexported fields
}
Component wrapper gin
func NewHttps ¶
func NewHttps(name, address, certFile, keyFile string, middleware ...gin.HandlerFunc) *Component
func NewWithOptions ¶
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
func (*Component) StaticFile ¶ added in v1.1.0
type Context ¶ added in v1.1.0
func (*Context) PostString ¶ added in v1.1.0
func (g *Context) PostString(name string, defaultValue string) string
func (*Context) RenderHTML ¶ added in v1.1.0
func (g *Context) RenderHTML(html string)
func (*Context) RenderJSON ¶ added in v1.1.0
func (g *Context) RenderJSON(value interface{})
func (*Context) RenderResult ¶ added in v1.1.3
type HandlerFunc ¶ added in v1.1.0
type HandlerFunc func(ctx *Context)
type IController ¶
Click to show internal directories.
Click to hide internal directories.