From 8ffa14d934a6ae46b1468cd636817c3e59c60727 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Mon, 5 Nov 2018 03:15:46 -0300 Subject: [PATCH] ratelimits.handler: add check for when rule is none (404s) --- litecord/ratelimits/handler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/litecord/ratelimits/handler.py b/litecord/ratelimits/handler.py index 715a283..9a8987e 100644 --- a/litecord/ratelimits/handler.py +++ b/litecord/ratelimits/handler.py @@ -58,6 +58,11 @@ async def ratelimit_handler(): """ rule = request.url_rule + if rule is None: + return await _handle_global( + app.ratelimiter.global_bucket + ) + # rule.endpoint is composed of '.' # and so we can use that to make routes with different # methods have different ratelimits @@ -73,5 +78,6 @@ async def ratelimit_handler(): ratelimit = app.ratelimiter.get_ratelimit(rule_path) await _handle_specific(ratelimit) except KeyError: - ratelimit = app.ratelimiter.global_bucket - await _handle_global(ratelimit) + await _handle_global( + app.ratelimiter.global_bucket + )