middleware

package
v0.0.0-...-00a40dd Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMiddleware

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

func NewAuthMiddleware

func NewAuthMiddleware(secret string) *AuthMiddleware

func (*AuthMiddleware) Authenticate

func (m *AuthMiddleware) Authenticate() fiber.Handler

func (*AuthMiddleware) RequireRole

func (m *AuthMiddleware) RequireRole(roles ...models.Role) fiber.Handler

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) GetCount

func (s *MemoryStore) GetCount(ctx context.Context, key string) (int, error)

func (*MemoryStore) Increment

func (s *MemoryStore) Increment(ctx context.Context, key string, window time.Duration) (int, error)

type RateLimitConfig

type RateLimitConfig struct {
	Enabled bool
	Limit   int
	Window  time.Duration
}

type RateLimitEntry

type RateLimitEntry struct {
	Count     int
	ExpiresAt time.Time
}

type RateLimitStore

type RateLimitStore interface {
	Increment(ctx context.Context, key string, window time.Duration) (int, error)
	GetCount(ctx context.Context, key string) (int, error)
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(store RateLimitStore, enabled bool) *RateLimiter

func (*RateLimiter) RateLimit

func (r *RateLimiter) RateLimit(config RateLimitConfig) fiber.Handler

type RedisStore

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

func NewRedisStore

func NewRedisStore(client *redis.Client) *RedisStore

func (*RedisStore) GetCount

func (s *RedisStore) GetCount(ctx context.Context, key string) (int, error)

func (*RedisStore) Increment

func (s *RedisStore) Increment(ctx context.Context, key string, window time.Duration) (int, error)

Jump to

Keyboard shortcuts

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