[routes] Await route function in decorator.

This commit is contained in:
Joël Maïzi 2020-07-30 11:11:40 +02:00
parent b8f1d3a35e
commit 14ab8bd346
1 changed files with 2 additions and 2 deletions

View File

@ -35,11 +35,11 @@ def get_routes(domains=None):
def route_decorator(fct, acls_mod, acls):
@wraps(fct)
def caller(req: Request, *args, **kwargs):
async def caller(req: Request, *args, **kwargs):
for acl_fct_name in acls:
acl_fct = getattr(acls_mod, acl_fct_name)
if acl_fct(req, *args, **kwargs):
return fct(req, *args, **kwargs)
return await fct(req, *args, **kwargs)
raise HTTPException(401)