Documentation
¶
Index ¶
- Constants
- Variables
- func AuthMiddleWare(config utils.Config, tokenMaker token.Maker, cache cache.Cache, ...) gin.HandlerFunc
- func RateLimit(rl *RateLimiter) gin.HandlerFunc
- func RateLimitMiddleware(rl *RateLimiterLb) gin.HandlerFunc
- type LeakyBucket
- type RateLimitConfig
- type RateLimiter
- type RateLimiterLb
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 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)
Click to show internal directories.
Click to hide internal directories.