middleware

package
v0.0.0-...-ea7d51e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRecoveryConfig = RecoveryConfig{
	StackAll:  false,
	StackSize: 1024 * 8,
	StackSkip: 3,
}

DefaultRecoveryConfig is the default recovery configs

View Source
var DefaultTraceConfig = TraceConfig{
	SkippedPathPrefixes: []string{"/health"},
	RequestHeaderKey:    "X-Request-Id",
	ResponseTraceKey:    "X-Trace-Id",
}

Functions

func Cors

func Cors() gin.HandlerFunc

func CorsWithConfig

func CorsWithConfig(cc cors.Config) gin.HandlerFunc

func Recovery

func Recovery(logger *zap.Logger) gin.HandlerFunc

Recovery returns a middleware for recovering from any panics and writes a 500 if there was one.

func RecoveryWithConfig

func RecoveryWithConfig(logger *zap.Logger, config RecoveryConfig) gin.HandlerFunc

RecoveryWithConfig returns a middleware for recovering from any panics and writes a 500 if there was one.

func SkippedPathPrefixes

func SkippedPathPrefixes(c *gin.Context, prefixes ...string) bool

func Trace

func Trace() gin.HandlerFunc

func TraceWithConfig

func TraceWithConfig(config TraceConfig) gin.HandlerFunc

Types

type Lark

type Lark struct {
	// contains filtered or unexported fields
}

func NewLarkMiddleware

func NewLarkMiddleware(cfg LarkConfig) *Lark

func (*Lark) GetCardHandle

func (l *Lark) GetCardHandle() *larkcard.CardActionHandler

func (*Lark) GetHandle

func (l *Lark) GetHandle() *dispatcher.EventDispatcher

type LarkConfig

type LarkConfig struct {
	AppId             string `json:"app_id"`
	Secret            string `json:"-"`
	EncryptKey        string `json:"-"`
	VerificationToken string `json:"-"`
}

type RecoveryConfig

type RecoveryConfig struct {
	StackAll  bool
	StackSize int
	StackSkip int
}

RecoveryConfig defines the configs for Recovery middleware

type TraceConfig

type TraceConfig struct {
	SkippedPathPrefixes []string
	RequestHeaderKey    string
	ResponseTraceKey    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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