middlewares

package
v0.0.0-...-d9c52e5 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeaderKey = "authorization"
)

Variables

View Source
var (
	AuthorizationPayloadKey = "authorization_payload"
)

Functions

func AuthMiddleWare

func AuthMiddleWare(config utils.Config, tokenMaker token.Maker, cache cache.Cache, accessibleRoles map[string][]int8) gin.HandlerFunc

I want to add authorization to this auth middleware. The idea is that endpoint will have the permissions assigned to it. EG get_menu endpoint might have only 1,2 roles. And will be the accessibleRoles. Refactor this to be able to fit the narrative Also note the full method should be used to index it so as to get the permissions(roles)

func RateLimit

func RateLimit(rl *RateLimiter) gin.HandlerFunc

func RateLimitMiddleware

func RateLimitMiddleware(rl *RateLimiterLb) gin.HandlerFunc

Types

type LeakyBucket

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

func (*LeakyBucket) Allow

func (lb *LeakyBucket) Allow() bool

type RateLimitConfig

type RateLimitConfig struct {
	Rate  rate.Limit
	Burst int
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) SetRateLimitConfig

func (rl *RateLimiter) SetRateLimitConfig(endpoint string, rateLimit RateLimitConfig)

type RateLimiterLb

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

func NewRateLimiterLb

func NewRateLimiterLb(capacity, rate int) *RateLimiterLb

func (*RateLimiterLb) CleanupOldBuckets

func (rl *RateLimiterLb) CleanupOldBuckets(interval time.Duration)

Jump to

Keyboard shortcuts

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