From 673097adeb4ccf2fec231feb3b3fcd8d14322542 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Fri, 1 Sep 2023 04:58:12 +0900 Subject: [PATCH] [half_domain] fix ACL route when checked ACL is a decorator --- halfapi/half_domain.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/halfapi/half_domain.py b/halfapi/half_domain.py index f1b781e..535cf9f 100644 --- a/halfapi/half_domain.py +++ b/halfapi/half_domain.py @@ -189,6 +189,20 @@ class HalfDomain(Starlette): } if elt.public: + try: + if inspect.iscoroutinefunction(fct): + logger.warning('async decorator are not yet supported') + else: + inner = fct() + + if inspect.iscoroutinefunction(fct) or callable(inner): + fct = inner + + except TypeError: + # Fct is not a decorator or is not well called (has no default arguments) + # We can ignore this + pass + routes.append( AclRoute(f'/{elt.name}', fct, elt) )