xecho

package module
v0.0.0-...-c285e0e Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyAuthErrorHandler

func KeyAuthErrorHandler(err error, _ echo.Context) error

KeyAuthErrorHandler is custom error handler for echo KeyAuth middleware. If this is not set, it's will convert all validator error to 401 error

func LoggerMid

func LoggerMid() echo.MiddlewareFunc

LoggerMid skip /status endpoint, will be deprecated.

func LoggerSkipper

func LoggerSkipper(c echo.Context) bool

LoggerSkipper skip the heartbeat /status log

func NewErrorHandler

func NewErrorHandler(logger *zap.Logger) echo.HTTPErrorHandler

NewErrorHandler return a customize echo's HTTP error handler.

func ZapLogger

func ZapLogger(log *zap.Logger) echo.MiddlewareFunc

ZapLogger use zap for echo logger

func ZapLoggerWithSkipper

func ZapLoggerWithSkipper(log *zap.Logger, skipper Skipper) echo.MiddlewareFunc

ZapLoggerWithSkipper use zap as request logger thank https://github.com/brpaz/echozap

Types

type Paginator

type Paginator struct {
	Page     int `query:"page" validate:"omitempty,min=1"`
	PageSize int `query:"page_size" validate:"omitempty,min=5,max=50"`
}

Paginator can be embedded to request struct You can check the input by mod validator If the value is wrong, It would be change to default

func (Paginator) AddHeader

func (p Paginator) AddHeader(c echo.Context, total int64)

AddHeader to echo resp

func (Paginator) Apply

func (p Paginator) Apply(tx *gorm.DB) *gorm.DB

Apply paginator to gorm query

func (Paginator) Offset

func (p Paginator) Offset() int

Offset will used by db query

type SkipRule

type SkipRule struct {
	Method     string
	Path       string
	StatusCode int
}

SkipRule must be fully equal

type Skipper

type Skipper func(ctx echo.Context) bool

func NewSkipper

func NewSkipper(rules []SkipRule) Skipper

NewSkipper gen a logger skipper

Jump to

Keyboard shortcuts

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