From aa4c309778e4c969fe1314da305e02112d4641b7 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Tue, 15 Jun 2021 09:45:37 +0200 Subject: [PATCH] [lib.domain] SUBROUTER can be a path parameter if including ":" --- halfapi/lib/domain.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/halfapi/lib/domain.py b/halfapi/lib/domain.py index 6cd641a..09b5aea 100644 --- a/halfapi/lib/domain.py +++ b/halfapi/lib/domain.py @@ -135,8 +135,6 @@ def gen_router_routes(m_router: ModuleType, path: List[str]) -> Generator: routes[''][verb.upper()] = [{ 'acl': acl.public }] - else: - print(f'no {verb.lower()} in {m_router}') routes['']['SUBROUTES'] = [] for item in os.listdir(list(m_router.__path__)[0]): @@ -153,7 +151,10 @@ def gen_router_routes(m_router: ModuleType, path: List[str]) -> Generator: subroutes = route_params.get('SUBROUTES', []) for subroute in subroutes: logger.debug('Processing subroute **%s** - %s', subroute, m_router.__name__) - path.append(subroute) + if ':' in subroute: + path.append(f'{{{subroute}}}') + else: + path.append(subroute) try: submod = importlib.import_module(f'.{subroute}', m_router.__name__) except ImportError as exc: