handler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleStorageRequest

func HandleStorageRequest(c echo.Context) error

Types

type Limiter

type Limiter struct {
	Size       time.Duration
	LastUpdate time.Time
	Mutex      *sync.Mutex
}

type ObjectStorage

type ObjectStorage struct {
	UserId     int    `json:"userId"`
	ObjectId   string `json:"objectId"`
	FileName   string `json:"fileName"`
	BucketName string `json:"bucketName"`
	SizeInByte int    `json:"sizeInByte"`
}

type RateLimit

type RateLimit struct {
	Limiters  *cache.Cache
	MaxTime   time.Duration
	TimeStep  time.Duration
	Config    *RateLimiterConfig
	WhiteList map[string]interface{}
	BlackList map[string]interface{}
}

func NewRateLimiter

func NewRateLimiter(config *RateLimiterConfig) *RateLimit

func (*RateLimit) Allow

func (rl *RateLimit) Allow(key string) bool

func (*RateLimit) Use

func (rl *RateLimit) Use(next echo.HandlerFunc) echo.HandlerFunc

type RateLimiterConfig

type RateLimiterConfig struct {
	Burst     int      `json:"burst"`
	Rate      int      `json:"rate"`
	WhiteList []string `json:"whitelist"`
	BlackList []string `json:"blacklist"`
}

Jump to

Keyboard shortcuts

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