cherryGin

package
v1.1.31 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 17 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 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

func SetMode added in v1.1.22

func SetMode(value string)

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 New

func New(name string, address string, opts ...OptionFunc) *Component

func NewHttp

func NewHttp(name, address string) *Component

func NewHttps

func NewHttps(name, address, certFile, keyFile string) *Component

func (*Component) Engine added in v1.1.29

func (g *Component) Engine() *gin.Engine

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

type Context added in v1.1.0

type Context struct {
	*gin.Context
}

func (*Context) GetBody added in v1.1.3

func (g *Context) GetBody() string

func (*Context) GetBool added in v1.1.3

func (g *Context) GetBool(name string, defaultValue bool, checkPost ...bool) bool

func (*Context) GetInt added in v1.1.0

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

func (*Context) GetInt32 added in v1.1.16

func (g *Context) GetInt32(name string, defaultValue int32, checkPost ...bool) int32

func (*Context) GetInt64 added in v1.1.0

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

func (*Context) GetParams added in v1.1.3

func (g *Context) GetParams(checkPost ...bool) map[string]string

func (*Context) GetString added in v1.1.0

func (g *Context) GetString(name, defaultValue string, checkPost ...bool) string

func (*Context) HTML200 added in v1.1.29

func (g *Context) HTML200(name string, obj ...interface{})

func (*Context) IsGet added in v1.1.29

func (g *Context) IsGet() bool

func (*Context) IsPost added in v1.1.29

func (g *Context) IsPost() bool

func (*Context) JSON200 added in v1.1.29

func (g *Context) JSON200(obj interface{})

func (*Context) PostFormInt32Array added in v1.1.29

func (g *Context) PostFormInt32Array(name string) []int32

func (*Context) PostFormInt64Array added in v1.1.29

func (g *Context) PostFormInt64Array(name string) []int64

func (*Context) PostFormIntArray added in v1.1.29

func (g *Context) PostFormIntArray(name string) []int

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) 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) RenderJsonString added in v1.1.21

func (g *Context) RenderJsonString(json string)

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:

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

type Options added in v1.1.1

type Options struct {
	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
	CertFile          string
	KeyFile           string
}

Options http server parameter

Jump to

Keyboard shortcuts

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