middleware

package
v2.0.77 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LIMIT = "limit:%s"
)

Variables

This section is empty.

Functions

func ApiMonitorMiddleware

func ApiMonitorMiddleware() gin.HandlerFunc

API监听

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

CORSMiddleware 跨域请求中间件

func CasbinMiddleware

func CasbinMiddleware(enforcer *casbin.SyncedEnforcer, skippers ...SkipperFunc) gin.HandlerFunc

CasbinMiddleware casbin中间件

func CopyBodyMiddleware

func CopyBodyMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

CopyBodyMiddleware Copy body

func DBMiddleware

func DBMiddleware(dbName string) gin.HandlerFunc

DBMiddleware 数据库切换中间件

func EmptyMiddleware

func EmptyMiddleware() gin.HandlerFunc

EmptyMiddleware 不执行业务处理的中间件

func GZIPMiddleware

func GZIPMiddleware() gin.HandlerFunc

GZIPMiddleware GZIP请求中间件

func JoinRouter

func JoinRouter(method, path string) string

JoinRouter 拼接路由

func LoggerMiddleware

func LoggerMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

LoggerMiddleware 日志中间件

func NoCacheMiddleware

func NoCacheMiddleware() gin.HandlerFunc

NoCacheMiddleware NoCache请求中间件

func NoMethodHandler

func NoMethodHandler() gin.HandlerFunc

NoMethodHandler 未找到请求方法的处理函数

func NoRouteHandler

func NoRouteHandler() gin.HandlerFunc

NoRouteHandler 未找到请求路由的处理函数

func RateLimiterMiddleware

func RateLimiterMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

RateLimiterMiddleware 请求频率限制中间件

func RecoveryMiddleware

func RecoveryMiddleware() gin.HandlerFunc

RecoveryMiddleware 崩溃恢复中间件

func Sentinel

func Sentinel(skippers ...SkipperFunc) gin.HandlerFunc

Sentinel 限流

func SkipHandler

func SkipHandler(c *gin.Context, skippers ...SkipperFunc) bool

SkipHandler 统一处理跳过函数

func TLSMiddleware

func TLSMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

TLSMiddleware TLS中间件

func TraceMiddleware

func TraceMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

TraceMiddleware 跟踪ID中间件

func UserAuthMiddleware

func UserAuthMiddleware(a auth.Auther, skippers ...SkipperFunc) gin.HandlerFunc

UserAuthMiddleware 用户授权中间件

func VersionMiddleware

func VersionMiddleware() gin.HandlerFunc

VersionMiddleware version中间件

func WWWMiddleware

func WWWMiddleware(skippers ...SkipperFunc) gin.HandlerFunc

WWWMiddleware 静态站点中间件

Types

type BodyLogWriter added in v2.0.70

type BodyLogWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

读取response

func (BodyLogWriter) Write added in v2.0.70

func (w BodyLogWriter) Write(b []byte) (int, error)

func (BodyLogWriter) WriteString added in v2.0.70

func (w BodyLogWriter) WriteString(s string) (n int, err error)

type BufferReadCloser added in v2.0.71

type BufferReadCloser struct {
	*bytes.Reader
}

设置request body

func NewBufferReadCloser added in v2.0.71

func NewBufferReadCloser(b []byte) *BufferReadCloser

func (*BufferReadCloser) Close added in v2.0.71

func (b *BufferReadCloser) Close() error

type SkipperFunc

type SkipperFunc func(*gin.Context) bool

SkipperFunc 定义中间件跳过函数

func AllowMethodAndPathPrefixSkipper

func AllowMethodAndPathPrefixSkipper(prefixes ...string) SkipperFunc

AllowMethodAndPathPrefixSkipper 检查请求方法和路径是否包含指定的前缀,如果不包含则跳过

func AllowPathPrefixNoSkipper

func AllowPathPrefixNoSkipper(prefixes ...string) SkipperFunc

AllowPathPrefixNoSkipper 检查请求路径是否包含指定的前缀,如果包含则不跳过

func AllowPathPrefixSkipper

func AllowPathPrefixSkipper(prefixes ...string) SkipperFunc

AllowPathPrefixSkipper 检查请求路径是否包含指定的前缀,如果包含则跳过

Jump to

Keyboard shortcuts

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