From ed6dcb05132d21fff837343327685983c03a4203 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Tue, 30 Nov 2021 01:49:37 +0100 Subject: [PATCH] [halfapi] application becomes a private attribute --- halfapi/halfapi.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/halfapi/halfapi.py b/halfapi/halfapi.py index 5f86b37..e7409d6 100644 --- a/halfapi/halfapi.py +++ b/halfapi/halfapi.py @@ -64,6 +64,8 @@ class HalfAPI: self.DOMAINS = DOMAINS self.SECRET = SECRET + self.__application = None + """ The base route contains the route schema """ self.api_routes = get_api_routes(DOMAINS) @@ -89,7 +91,8 @@ class HalfAPI: ) - self.application = Starlette( + + self.__application = Starlette( debug=not PRODUCTION, routes=routes, exception_handlers={ @@ -101,24 +104,24 @@ class HalfAPI: } ) - self.application.add_middleware( + self.__application.add_middleware( DomainMiddleware, config=CONFIG ) if SECRET: self.SECRET = SECRET - self.application.add_middleware( + self.__application.add_middleware( AuthenticationMiddleware, backend=JWTAuthenticationBackend(secret_key=SECRET) ) if not PRODUCTION: - self.application.add_middleware( + self.__application.add_middleware( TimingMiddleware, client=HTimingClient(), metric_namer=StarletteScopeToName(prefix="halfapi", - starlette_app=self.application) + starlette_app=self.__application) ) @@ -129,6 +132,10 @@ class HalfAPI: async def version_async(self, request, *args, **kwargs): return Response(self.version) + @property + def application(self): + return self.__application + def routes(self): """ Halfapi default routes """