diff --git a/halfapi/lib/routes.py b/halfapi/lib/routes.py index 293949f..de3294f 100644 --- a/halfapi/lib/routes.py +++ b/halfapi/lib/routes.py @@ -14,7 +14,7 @@ Exception : """ from datetime import datetime -from functools import wraps +from functools import partial, wraps import logging from typing import Callable, List, Dict, Generator from types import ModuleType, FunctionType @@ -33,7 +33,7 @@ class DomainNotFoundError(Exception): """ Exception when a domain is not importable """ -def route_acl_decorator(fct: Callable, params: List[Dict]): +def route_acl_decorator(fct: Callable = None, params: List[Dict] = []): """ Decorator for async functions that calls pre-conditions functions and appends kwargs to the target function @@ -50,6 +50,10 @@ def route_acl_decorator(fct: Callable, params: List[Dict]): async function """ + if not fct: + return partial(route_acl_decorator, params=params) + + @wraps(fct) async def caller(req: Request, *args, **kwargs): for param in params: