feat: add configuration loader for .env and JSON files
- Add ConfigLoader class for loading RateLimitConfig and GlobalConfig - Support .env files with FASTAPI_TRAFFIC_* prefixed variables - Support JSON configuration files with type validation - Add convenience functions: load_rate_limit_config, load_global_config - Add load_rate_limit_config_from_env, load_global_config_from_env - Support custom environment variable prefixes - Add comprehensive error handling with ConfigurationError - Add 47 tests for configuration loading - Add example 11_config_loader.py with 9 usage patterns - Update examples/README.md with config loader documentation - Update CHANGELOG.md with new feature - Fix typo in limiter.py (errant 'fi' on line 4)
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
"""Core rate limiting components."""
|
||||
|
||||
from fastapi_traffic.core.algorithms import Algorithm
|
||||
from fastapi_traffic.core.config import RateLimitConfig
|
||||
from fastapi_traffic.core.config import GlobalConfig, RateLimitConfig
|
||||
from fastapi_traffic.core.config_loader import (
|
||||
ConfigLoader,
|
||||
load_global_config,
|
||||
load_global_config_from_env,
|
||||
load_rate_limit_config,
|
||||
load_rate_limit_config_from_env,
|
||||
)
|
||||
from fastapi_traffic.core.decorator import rate_limit
|
||||
from fastapi_traffic.core.limiter import RateLimiter
|
||||
from fastapi_traffic.core.models import RateLimitInfo, RateLimitResult
|
||||
|
||||
__all__ = [
|
||||
"Algorithm",
|
||||
"ConfigLoader",
|
||||
"GlobalConfig",
|
||||
"RateLimitConfig",
|
||||
"rate_limit",
|
||||
"RateLimiter",
|
||||
"RateLimitInfo",
|
||||
"RateLimitResult",
|
||||
"RateLimiter",
|
||||
"load_global_config",
|
||||
"load_global_config_from_env",
|
||||
"load_rate_limit_config",
|
||||
"load_rate_limit_config_from_env",
|
||||
"rate_limit",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user