Utils
get_api_routes
get_api_routes(
router: SupportsRoutes,
) -> Generator[APIRoute, None, None]
Generator that yields APIRoute objects from an APIRouter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
router |
SupportsRoutes
|
router object, can be |
required |
Yields:
| Type | Description |
|---|---|
APIRoute
|
Generator[APIRoute, None, None]: the |
Source code in fastlimits/utils.py
find_api_route
find_api_route(
router: SupportsRoutes, func: Callable[..., Any]
) -> Optional[APIRoute]
Find the APIRoute object from the APIRouter.routes or FastAPI.routes
Source code in fastlimits/utils.py
create_response_model
create_response_model(
model: Type[ModelT],
parsed_limit: RateLimitItem,
show_limit_in_response_model: bool = False,
) -> Type[ModelT]
Returns a copy of the model with the default value updated and placeholders filled.G
Source code in fastlimits/utils.py
fncopy
creates a deepcopy of a function with the same code, globals, defaults, closures but slighlty different signature
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func |
Callable[P, R]
|
the function to create a copy of |
required |
sig |
tuple[Parameter]
|
new parameters |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., R]
|
Callable[P, R]: the copied new function |
Source code in fastlimits/utils.py
ensure_list
ensure the value is a list
returns an empty list if value is None