Add --req-limit-storage redis support
This commit is contained in:
parent
bc8b331fe9
commit
70c4571067
5 changed files with 15 additions and 0 deletions
|
|
@ -161,6 +161,7 @@ def create_app(args):
|
|||
default_limits=get_routes_limits(
|
||||
args.req_limit, args.daily_req_limit, api_keys_db
|
||||
),
|
||||
storage_uri=args.req_limit_storage,
|
||||
)
|
||||
else:
|
||||
from .no_limiter import Limiter
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ _default_options_objects = [
|
|||
'default_value': -1,
|
||||
'value_type': 'int'
|
||||
},
|
||||
{
|
||||
'name': 'REQ_LIMIT_STORAGE',
|
||||
'default_value': 'memory://',
|
||||
'value_type': 'str'
|
||||
},
|
||||
{
|
||||
'name': 'DAILY_REQ_LIMIT',
|
||||
'default_value': -1,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ def get_args():
|
|||
metavar="<number>",
|
||||
help="Set the default maximum number of requests per minute per client (%(default)s)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--req-limit-storage",
|
||||
default=DEFARGS['REQ_LIMIT_STORAGE'],
|
||||
type=str,
|
||||
metavar="<Storage URI>",
|
||||
help="Storage URI to use for request limit data storage. See https://flask-limiter.readthedocs.io/en/stable/configuration.html. (%(default)s)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--daily-req-limit",
|
||||
default=DEFARGS['DAILY_REQ_LIMIT'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue