21 lines
533 B
Python
21 lines
533 B
Python
"""
|
|
Rate Limiter - ServiceManagerWeb
|
|
|
|
Configura slowapi con Redis como storage backend.
|
|
Respeta settings.RATE_LIMIT_ENABLED: si está desactivado usa memoria
|
|
y el limiter queda en modo noop (enabled=False).
|
|
"""
|
|
|
|
from slowapi import Limiter
|
|
from slowapi.util import get_remote_address
|
|
|
|
from app.core.config import get_settings
|
|
|
|
settings = get_settings()
|
|
|
|
limiter = Limiter(
|
|
key_func=get_remote_address,
|
|
storage_uri=settings.REDIS_URL if settings.RATE_LIMIT_ENABLED else "memory://",
|
|
enabled=settings.RATE_LIMIT_ENABLED,
|
|
)
|