middleware

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALLOW       = "ALLOW"
	ALLOWWEIGHT = 90
)
View Source
const (
	CORS       = "CORS"
	CORSWEIGHT = 50
)
View Source
const (
	ACCESSLOG       = "ACCESSLOG"
	ACCESSLOGWEIGHT = 101
	STACKLOG        = "STACKLOG"
	STACKLOGWEIGHT  = 102
)
View Source
const (
	METRICS       = "METRICS"
	METRICSWEIGHT = 80
)
View Source
const (
	REQUESTINFO       = "REQUESTINFO"
	REQUESTINFOWEIGHT = 120
)

Variables

View Source
var (
	ErrMiddlewareRegisterNil    = fmt.Errorf("middleware: Register adapter is nil")
	ErrMiddlewareDoubleRegister = fmt.Errorf("middleware: Register called twice for adapter: ")
)

Functions

func Allowz

func Allowz() gin.HandlerFunc

func Cors

func Cors() gin.HandlerFunc

处理跨域请求,支持options访问.

func IsAllow

func IsAllow(c *gin.Context) bool

func ListPlugins

func ListPlugins() []string

CLI 调用方法.

func Logging

func Logging() gin.HandlerFunc

access logging.

func MetricsFunc

func MetricsFunc() gin.HandlerFunc

func Recovery

func Recovery() gin.HandlerFunc

func Register

func Register(plugin *Instance)

func RequestInfo

func RequestInfo() gin.HandlerFunc

Types

type AllowConfig

type AllowConfig struct {
	HostAllowDomain bool
	HostAllowIP     bool
}

type Instance

type Instance struct {
	F      func() gin.HandlerFunc // middle instance
	Weight uint                   // plugin load weight 越大到越靠前load
	Name   string                 // plugin name
}

func AllMiddlewarePlugins

func AllMiddlewarePlugins() []*Instance

type Instances

type Instances []*Instance

func (Instances) In

func (s Instances) In(n *Instance) bool

func (Instances) Len

func (s Instances) Len() int

func (Instances) Less

func (s Instances) Less(i, j int) bool

func (Instances) Swap

func (s Instances) Swap(i, j int)

type String

type String string

Jump to

Keyboard shortcuts

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