middleware

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 22 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
)
View Source
const (
	TRACING       = "TRACING"
	TRACINGWEIGHT = 130
)

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(_ string) gin.HandlerFunc

func Cors

func Cors(_ string) gin.HandlerFunc

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

func IsAllow

func IsAllow(c *gin.Context) bool

func ListPlugins

func ListPlugins() []string

CLI 调用方法.

func Logging

func Logging(_ string) gin.HandlerFunc

access logging.

func MetricsFunc

func MetricsFunc(_ string) gin.HandlerFunc

func Recovery

func Recovery(_ string) gin.HandlerFunc

func Register

func Register(plugin *Instance)

func RequestInfo

func RequestInfo(_ string) gin.HandlerFunc

func TracingFunc added in v1.3.0

func TracingFunc(serviceName string) gin.HandlerFunc

TracingFunc returns interceptor that will trace incoming requests. The service parameter should describe the name of the (virtual) server handling the request.

Types

type AllowConfig

type AllowConfig struct {
	HostAllowDomain bool
	HostAllowIP     bool
}

type Instance

type Instance struct {
	F      func(servicename string) 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

type TraceOption added in v1.3.0

type TraceOption func(*traceConfig)

TraceOption specifies instrumentation configuration options.

func WithPropagators added in v1.3.0

func WithPropagators(propagators propagation.TextMapPropagator) TraceOption

WithPropagators specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.

func WithTracerProvider added in v1.3.0

func WithTracerProvider(provider oteltrace.TracerProvider) TraceOption

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

Jump to

Keyboard shortcuts

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