middleware

package
v0.0.0-...-2472da9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

README

middleware

web中间件

Documentation

Index

Constants

View Source
const HeaderKey = "X-Request-Id"

Variables

View Source
var CacheKeyAlgorithmMap = make(map[string]CacheKeyAlgorithm)
View Source
var DefaultAuthConfig = &AuthConfig{}
View Source
var DefaultLoggerConfig = &LoggerConfig{}

Functions

func EchoAsync

func EchoAsync() echo.MiddlewareFunc

EchoAsync 用于 echo 框架的异步处理中间件

func EchoAuth

func EchoAuth() echo.MiddlewareFunc

func EchoAuthWithConfig

func EchoAuthWithConfig(authConfig *AuthConfig) echo.MiddlewareFunc

EchoAuth 用于 echo 框架的签名校验中间件

func EchoCache

func EchoCache(cacheMaxEntryNum ...int) echo.MiddlewareFunc

EchoCache 用于 echo 框架的缓存中间件。支持自定义 cache 数量

func EchoLogger

func EchoLogger() echo.MiddlewareFunc

func EchoLoggerWitchConfig

func EchoLoggerWitchConfig(loggerConfig *LoggerConfig) echo.MiddlewareFunc

EchoLoggerWitchConfig 用于 echo 框架的日志中间件

Types

type AuthConfig

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

func NewAuthConfig

func NewAuthConfig(signature func(url.Values, string) string, secretKey string) *AuthConfig

type CacheKeyAlgorithm

type CacheKeyAlgorithm interface {
	GenCacheKey(echo.Context) string
}

type CacheKeyFunc

type CacheKeyFunc func(echo.Context) string

func (CacheKeyFunc) GenCacheKey

func (self CacheKeyFunc) GenCacheKey(ctx echo.Context) string

type LoggerConfig

type LoggerConfig struct {
	// 是否输出 POST 参数,默认不输出
	OutputPost bool
	// 当 OutputPost 为 true 时,排除这些 path,避免包含敏感信息输出
	Excludes map[string]struct{}
}

type Stats

type Stats struct {
	Uptime       time.Time      `json:"uptime"`
	RequestCount uint64         `json:"request_count"`
	Statuses     map[string]int `json:"statuses"`
	// contains filtered or unexported fields
}

func NewStats

func NewStats() *Stats

func (*Stats) Handle

func (s *Stats) Handle(c echo.Context) error

Handle is the endpoint to get stats.

func (*Stats) Process

func (s *Stats) Process() echo.MiddlewareFunc

Jump to

Keyboard shortcuts

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