bohea / sanic-limiter

Provides rate limiting features for Sanic. Supports in-memory, redis and memcache as storage.
MIT License
85 stars 14 forks source link

Unable to use in blueprint files #12

Closed AggressivelyMeows closed 5 years ago

AggressivelyMeows commented 5 years ago

I cannot find a way to use this in blueprint files. Every attempt leads to the same issue:

[2019-06-27 20:12:41 +0000] [32202] [ERROR] Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sanic/app.py", line 584, in handle_request
    response = await self._run_request_middleware(request)
  File "/usr/local/lib/python3.6/dist-packages/spf/framework.py", line 466, in _run_request_middleware
    response = middleware(request)
  File "/usr/local/lib/python3.6/dist-packages/sanic_limiter/extension.py", line 155, in __check_request_limit
    view_handler = self.app.router.routes_static.get(endpoint, None)
AttributeError: 'NoneType' object has no attribute 'router

The limiter is added via init_app in before_server_start. I want to have a common limiter that i can import insted of having to make a limiter per blueprint file as i have many files

bohea commented 5 years ago

I think @J-France fixed this bug #13