Пример #1
0
 def add_router(
     self,
     prefix: str,
     router: Router,
     *,
     auth: Any = NOT_SET,
     tags: Optional[List[str]] = None,
 ) -> None:
     if auth != NOT_SET:
         router.auth = auth
     if tags is not None:
         router.tags = tags
     self._routers.extend(router.build_routers(prefix))
     router.set_api_instance(self)
Пример #2
0
    def add_router(
        self,
        prefix: str,
        router: Router,
        *,
        auth: Any = NOT_SET,
        tags: Optional[List[str]] = None,
        parent_router: Router = None,
    ) -> None:
        if auth != NOT_SET:
            router.auth = auth
        if tags is not None:
            router.tags = tags

        if parent_router:
            parent_prefix = next(  # pragma: no cover
                (path for path, r in self._routers if r is parent_router), None
            )
            assert parent_prefix is not None
            prefix = normalize_path("/".join((parent_prefix, prefix))).lstrip("/")

        self._routers.extend(router.build_routers(prefix))
        router.set_api_instance(self)