middleware

package
v0.0.0-...-7f5b3d9 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIPNotAllow = &hes.Error{
		StatusCode: http.StatusBadRequest,
		Message:    "request is forbidden",
		Category:   "IB",
	}
)

Functions

func NewConcurrentLimit

func NewConcurrentLimit(keys []string, ttl time.Duration, prefix string) elton.Handler

NewConcurrentLimit 创建并发限制的中间件

func NewConcurrentLimitWithDone

func NewConcurrentLimitWithDone(keys []string, ttl time.Duration, prefix string) elton.Handler

NewConcurrentLimitWithDone 创建并发限制中间件,完成时则执行done清除

func NewEntry

func NewEntry(entryFn EntryFunc, exitFn ExitFunc) elton.Handler

NewEntry create an entry middleware

func NewError

func NewError() elton.Handler

New Error handler

func NewErrorLimit

func NewErrorLimit(maxCount int64, ttl time.Duration, fn KeyGenerator) elton.Handler

NewErrorLimit 创建出错限制中间件

func NewIPBlocker

func NewIPBlocker(fn IPBlockFunc) elton.Handler

NewIPBlocker create a new block ip middleware

func NewIPLimit

func NewIPLimit(maxCount int64, ttl time.Duration, prefix string) elton.Handler

NewIPLimit 创建IP限制中间件

func NewInterceptor

func NewInterceptor() elton.Handler

func NewMethodNotAllowedHandler

func NewMethodNotAllowedHandler() http.HandlerFunc

NewMethodNotAllowedHandler 创建method not allowed的处理函数

func NewNoCacheWithCondition

func NewNoCacheWithCondition(key, value string) elton.Handler

NewNoCacheWithCondition 创建no cache的中间件,此中间件根据设置的key value来判断是否设置为no cache

func NewNotFoundHandler

func NewNotFoundHandler() http.HandlerFunc

NewNotFoundHandler 创建404 not found的处理函数

func NewPrefixHandler

func NewPrefixHandler(prefixes []string) elton.PreHandler

NewPrefixHandler create a new request url prefix handler

func NewRouterMocker

func NewRouterMocker(fn GetConfigFunc) elton.Handler

NewRouterMocker create a router mocker

func NewStats

func NewStats(processingCount *atomic.Int32) elton.Handler

func ValidateCaptcha

func ValidateCaptcha(magicalCaptcha string) elton.Handler

ValidateCaptcha 图形难码校验

func WaitFor

func WaitFor(d time.Duration, onlyErrOccurreds ...bool) elton.Handler

WaitFor 延时响应中间件,设置最少等待多久再响应

Types

type EntryFunc

type EntryFunc func() int32

type ExitFunc

type ExitFunc func() int32

type GetConfigFunc

type GetConfigFunc func(method, route string) *routermock.RouterMock

type IPBlockFunc

type IPBlockFunc func(string) bool

type KeyGenerator

type KeyGenerator func(c *elton.Context) string

KeyGenerator key generator

Jump to

Keyboard shortcuts

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