Documentation
¶
Overview ¶
Package cherryGin from https://github.com/gin-contrib/zap/
Index ¶
- Constants
- 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) GetInt32Cookie(name string, defaultValue int32) int32
- func (g *Context) GetInt64(name string, defaultValue int64, checkPost ...bool) int64
- func (g *Context) GetInt64Cookie(name string, defaultValue int64) int64
- func (g *Context) GetIntCookie(name string, defaultValue int) int
- func (g *Context) GetParams(checkPost ...bool) map[string]string
- func (g *Context) GetString(name, defaultValue string, checkPost ...bool) string
- func (g *Context) GetStringCookie(name string, defaultValue string) 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) PostInt32(name string, defaultValue int32) int32
- 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 ¶
View Source
const (
NamePrefix = "gin_component_"
)
Variables ¶
This section is empty.
Functions ¶
func BindHandler ¶
func BindHandler(handler func(ctx *Context)) gin.HandlerFunc
func BindHandlers ¶
func BindHandlers(handlers []GinHandlerFunc) []gin.HandlerFunc
Types ¶
type BaseController ¶
type BaseController struct { App cfacade.IApplication Engine *gin.Engine }
func (*BaseController) Any ¶
func (b *BaseController) Any(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) GET ¶
func (b *BaseController) GET(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) Group ¶
func (b *BaseController) Group(relativePath string, handlers ...GinHandlerFunc) *Group
func (*BaseController) Init ¶
func (b *BaseController) Init()
func (*BaseController) POST ¶
func (b *BaseController) POST(relativePath string, handlers ...GinHandlerFunc)
func (*BaseController) PreInit ¶
func (b *BaseController) PreInit(app cfacade.IApplication, engine *gin.Engine)
func (*BaseController) Stop ¶
func (b *BaseController) Stop()
type Component ¶
type Component struct { cfacade.Component *HttpServer // contains filtered or unexported fields }
Component wrapper gin
func (*Component) OnAfterInit ¶
func (g *Component) OnAfterInit()
func (*Component) OnBeforeStop ¶
func (g *Component) OnBeforeStop()
func (*Component) Register ¶
func (g *Component) Register(controllers ...IController) *Component
type Context ¶
func (*Context) GetInt32Cookie ¶ added in v1.2.4
func (*Context) GetInt64Cookie ¶ added in v1.2.4
func (*Context) GetIntCookie ¶ added in v1.2.4
func (*Context) GetStringCookie ¶ added in v1.2.4
func (*Context) PostFormInt32Array ¶
func (*Context) PostFormInt64Array ¶
func (*Context) PostFormIntArray ¶
func (*Context) RenderHTML ¶
func (*Context) RenderJSON ¶
func (g *Context) RenderJSON(value interface{})
func (*Context) RenderJsonString ¶
type GinHandlerFunc ¶
type GinHandlerFunc func(ctx *Context)
func Cors ¶
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 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 ¶
type Group struct {
*gin.RouterGroup
}
func (*Group) Any ¶
func (p *Group) Any(relativePath string, handlers ...GinHandlerFunc)
func (*Group) GET ¶
func (p *Group) GET(relativePath string, handlers ...GinHandlerFunc)
func (*Group) POST ¶
func (p *Group) POST(relativePath string, handlers ...GinHandlerFunc)
type HttpServer ¶
type HttpServer struct { cfacade.IApplication Options *gin.Engine // contains filtered or unexported fields }
func NewHttpServer ¶
func NewHttpServer(address string, opts ...OptionFunc) *HttpServer
func (*HttpServer) Register ¶
func (p *HttpServer) Register(controllers ...IController) *HttpServer
func (*HttpServer) Run ¶
func (p *HttpServer) Run()
func (*HttpServer) SetIApplication ¶
func (p *HttpServer) SetIApplication(app cfacade.IApplication)
func (*HttpServer) Static ¶
func (p *HttpServer) Static(relativePath string, staticDir string)
func (*HttpServer) StaticFile ¶
func (p *HttpServer) StaticFile(relativePath, filepath string)
func (*HttpServer) Stop ¶
func (p *HttpServer) Stop()
func (*HttpServer) Use ¶
func (p *HttpServer) Use(middleware ...GinHandlerFunc)
type IController ¶
type IController interface { PreInit(app cfacade.IApplication, engine *gin.Engine) Init() Stop() }
type OptionFunc ¶
type OptionFunc func(opts *Options)
func WithCert ¶
func WithCert(certFile, keyFile string) OptionFunc
func WithIdleTimeout ¶
func WithIdleTimeout(t time.Duration) OptionFunc
func WithMaxHeaderBytes ¶
func WithMaxHeaderBytes(val int) OptionFunc
func WithReadHeaderTimeout ¶
func WithReadHeaderTimeout(t time.Duration) OptionFunc
func WithReadTimeout ¶
func WithReadTimeout(t time.Duration) OptionFunc
Click to show internal directories.
Click to hide internal directories.