cherryGin

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cherryGin from https://github.com/gin-contrib/zap/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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:

  1. A time package format string (e.g. time.RFC3339).
  2. 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

type BaseController struct {
	App    cherryFacade.IApplication
	Engine *gin.Engine
}

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 New

func New(address string, middleware ...gin.HandlerFunc) *Component

func NewHttp

func NewHttp(name, address string, middleware ...gin.HandlerFunc) *Component

func NewHttps

func NewHttps(name, address, certFile, keyFile string, middleware ...gin.HandlerFunc) *Component

func NewWithOptions

func NewWithOptions(name string, options Options) *Component

func (*Component) Init added in v1.1.0

func (g *Component) Init()

func (*Component) Name added in v1.1.0

func (g *Component) Name() string

Name unique components name

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) OnStop added in v1.1.0

func (g *Component) OnStop()

func (*Component) Register added in v1.1.0

func (g *Component) Register(controllers ...IController) *Component

func (*Component) StaticFS added in v1.1.0

func (g *Component) StaticFS(relativePath string, staticDir string)

func (*Component) StaticFile added in v1.1.0

func (g *Component) StaticFile(relativePath string, staticDir string)

type Context added in v1.1.0

type Context struct {
	*gin.Context
}

func (*Context) GetInt added in v1.1.0

func (g *Context) GetInt(name string, defaultValue int) int

func (*Context) GetInt64 added in v1.1.0

func (g *Context) GetInt64(name string, defaultValue int64) int64

func (*Context) GetString added in v1.1.0

func (g *Context) GetString(name string, defaultValue string) string

func (*Context) PostInt added in v1.1.0

func (g *Context) PostInt(name string, defaultValue int) int

func (*Context) PostInt64 added in v1.1.0

func (g *Context) PostInt64(name string, defaultValue int64) int64

func (*Context) PostString added in v1.1.0

func (g *Context) PostString(name string, defaultValue string) string

func (*Context) RenderError added in v1.1.0

func (g *Context) RenderError(code int, msg 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{})

type HandlerFunc added in v1.1.0

type HandlerFunc func(ctx *Context)

type IController

type IController interface {
	PreInit(app cherryFacade.IApplication, engine *gin.Engine)

	Init()

	Stop()
}

type Options added in v1.1.1

type Options struct {
	ReadTimeout       time.Duration // http server parameter
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
	Address           string
	CertFile          string
	KeyFile           string
}

Jump to

Keyboard shortcuts

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