Documentation
¶
Index ¶
- Variables
- func CircuitBreaker(config CircuitBreakerConfig) echo.MiddlewareFunc
- func InitValidate(e *echo.Echo)
- func Logger() echo.MiddlewareFunc
- func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc
- func NewDefaultStore() limiter.Store
- func Recover() echo.MiddlewareFunc
- func RecoverWithConfig(config *RecoverConfig) echo.MiddlewareFunc
- func RouteReachedLimitGlobal(limit int64, period time.Duration) echo.MiddlewareFunc
- func RouteReachedLimitLocal(limit int64, period time.Duration) echo.MiddlewareFunc
- func RouteUserLimitGlobal(limit int64, period time.Duration) echo.MiddlewareFunc
- func SetErrNotifyUrl(s string)
- func SetLimitStoreOptionsConfig(c LimitStoreOptionsConfig)
- type BodyDumpHandler
- type CircuitBreakerConfig
- type CustomBinder
- type LimitStoreOptionsConfig
- type LoggerConfig
- type RecoverConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultLoggerConfig is the default Logger middleware config. DefaultLoggerConfig = LoggerConfig{ Skipper: func(context echo.Context) bool { if strings.Index(context.Request().URL.Path, "/swagger") != -1 { return true } return false }, // contains filtered or unexported fields } )
Functions ¶
func CircuitBreaker ¶
func CircuitBreaker(config CircuitBreakerConfig) echo.MiddlewareFunc
CircuitBreaker 断路器中间件
func InitValidate ¶
func InitValidate(e *echo.Echo)
func LoggerWithConfig ¶
func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc
LoggerWithConfig returns a Logger middleware with config. See: `Logger()`.
func Recover ¶
func Recover() echo.MiddlewareFunc
Recover returns a middleware which recovers from panics anywhere in the chain and handles the control to the centralized HTTPErrorHandler.
func RecoverWithConfig ¶
func RecoverWithConfig(config *RecoverConfig) echo.MiddlewareFunc
RecoverWithConfig returns a Recover middleware with config. See: `Recover()`.
func RouteReachedLimitGlobal ¶
api接口全局限流器
func RouteReachedLimitLocal ¶
api接口本地限流器
func RouteUserLimitGlobal ¶
RouteUserLimitGlobal api接口单用户全局限流器
func SetLimitStoreOptionsConfig ¶
func SetLimitStoreOptionsConfig(c LimitStoreOptionsConfig)
Types ¶
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct { Skipper middleware.Skipper Name string `json:"name"` // should be unique Timeout int `json:"timeout"` MaxConcurrentRequests int `json:"max_concurrent_requests"` RequestVolumeThreshold int `json:"request_volume_threshold"` SleepWindow int `json:"sleep_window"` ErrorPercentThreshold int `json:"error_percent_threshold"` }
CircuitBreakerConfig 断路器配置 Name 需保证唯一
type CustomBinder ¶
type CustomBinder struct{}
CustomBinder 自定bind
func (*CustomBinder) Bind ¶
func (cb *CustomBinder) Bind(i interface{}, e echo.Context) (err error)
Bind 自定义bind
type LimitStoreOptionsConfig ¶
type LoggerConfig ¶
type LoggerConfig struct { // Skipper defines a function to skip middleware. Skipper echoMiddleware.Skipper // Output is a writer where logs in JSON format are written. // Optional. Default value os.Stdout. Output io.Writer Handler BodyDumpHandler // contains filtered or unexported fields }
LoggerConfig defines the config for Logger middleware.
type RecoverConfig ¶
type RecoverConfig struct { // Skipper defines a function to skip middleware. Skipper echoMiddleware.Skipper // Size of the stack to be printed. // Optional. Default value 4KB. StackSize int `yaml:"stack_size"` // DisableStackAll disables formatting stack traces of all other goroutines // into buffer after the trace for the current goroutine. // Optional. Default value false. DisableStackAll bool `yaml:"disable_stack_all"` // DisablePrintStack disables printing stack trace. // Optional. Default value as false. DisablePrintStack bool `yaml:"disable_print_stack"` // LogLevel is log level to printing stack trace. // Optional. Default value 0 (Print). LogLevel log.Lvl }
RecoverConfig defines the config for Recover middleware.
Click to show internal directories.
Click to hide internal directories.