Dependencies
BaseLimiterDependency
This dpendency will be injected into the APIRoute object and does the actual 'limiting' job.
Source code in fastlimits/dependencies.py
no_hit_status_codes
instance-attribute
no_hit_status_codes = (
no_hit_status_codes if no_hit_status_codes else []
)
__init__
__init__(
limit_value: Union[str, RateLimitItem],
no_hit_status_codes: Optional[List[int]] = None,
) -> None
BaseLimiterDependency
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit_value |
Union[str, RateLimitItem]
|
a string like "5/minute" or a |
required |
no_hit_status_codes |
Optional[List[int]]
|
the response statuses that won't be count as a hit on the limiter. |
None
|
Source code in fastlimits/dependencies.py
__call__
async
The actual callable that FastAPI call and checks for rate-limiting
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request
|
request object from FastAPI |
required |
response |
Response
|
response object from FastAPI |
required |
keys |
Optional[List[str]]
|
extra keys other than those provided by the middleware as identifiers for a rate-limit item |
None
|
Raises:
| Type | Description |
|---|---|
RateLimitExceeded
|
when the rate limit exceeds the allowed value |
Source code in fastlimits/dependencies.py
_InjectedLimiterDependency
Bases: BaseLimiterDependency
A modified version of this class will be injected into the
APIRoute dependencies to trick FastAPI to resolve the dependencies inside of the functions passed from
filter argument of limit decorator.
Source code in fastlimits/dependencies.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
__call__
async
apply_dependencies
classmethod
apply_dependencies(
keys: Optional[
Union[StrOrCallableKey, List[StrOrCallableKey]]
],
filters: Optional[
Union[CallableFilter, List[CallableFilter]]
],
) -> Type[_InjectedLimiterDependency]
Applies the filters and keys provided by the caller to a modified version of this class and returns it
Returns:
| Type | Description |
|---|---|
Type[_InjectedLimiterDependency]
|
Type[_injectedLimiterDependency]: |