cherryGin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

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 BaseIController

type BaseIController struct {
	App    cherryInterfaces.IApplication
	Engine *gin.Engine
}

func (*BaseIController) Init

func (b *BaseIController) Init()

func (*BaseIController) PreInit

func (b *BaseIController) PreInit(app cherryInterfaces.IApplication, engine *gin.Engine)

func (*BaseIController) Stop

func (b *BaseIController) Stop()

type GinComponent

type GinComponent struct {
	cherryInterfaces.BaseComponent
	// contains filtered or unexported fields
}

func New

func New(address string) *GinComponent

func NewHttp

func NewHttp(name, address string) *GinComponent

func NewHttps

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

func NewWithOptions

func NewWithOptions(name string, options GinComponentOptions) *GinComponent

func (*GinComponent) AfterInit

func (g *GinComponent) AfterInit()

func (*GinComponent) BeforeStop

func (g *GinComponent) BeforeStop()

func (*GinComponent) GetEngine

func (g *GinComponent) GetEngine() *gin.Engine

func (*GinComponent) Init

func (g *GinComponent) Init()

func (*GinComponent) Name

func (g *GinComponent) Name() string

Name unique components name

func (*GinComponent) Register

func (g *GinComponent) Register(controller IController)

func (*GinComponent) Stop

func (g *GinComponent) Stop()

type GinComponentOptions

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

type IController

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

	Init()

	Stop()
}

Jump to

Keyboard shortcuts

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