[halfapi] application becomes a private attribute
This commit is contained in:
parent
7017827b2b
commit
ed6dcb0513
@ -64,6 +64,8 @@ class HalfAPI:
|
|||||||
self.DOMAINS = DOMAINS
|
self.DOMAINS = DOMAINS
|
||||||
self.SECRET = SECRET
|
self.SECRET = SECRET
|
||||||
|
|
||||||
|
self.__application = None
|
||||||
|
|
||||||
""" The base route contains the route schema
|
""" The base route contains the route schema
|
||||||
"""
|
"""
|
||||||
self.api_routes = get_api_routes(DOMAINS)
|
self.api_routes = get_api_routes(DOMAINS)
|
||||||
@ -89,7 +91,8 @@ class HalfAPI:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
self.application = Starlette(
|
|
||||||
|
self.__application = Starlette(
|
||||||
debug=not PRODUCTION,
|
debug=not PRODUCTION,
|
||||||
routes=routes,
|
routes=routes,
|
||||||
exception_handlers={
|
exception_handlers={
|
||||||
@ -101,24 +104,24 @@ class HalfAPI:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.application.add_middleware(
|
self.__application.add_middleware(
|
||||||
DomainMiddleware,
|
DomainMiddleware,
|
||||||
config=CONFIG
|
config=CONFIG
|
||||||
)
|
)
|
||||||
|
|
||||||
if SECRET:
|
if SECRET:
|
||||||
self.SECRET = SECRET
|
self.SECRET = SECRET
|
||||||
self.application.add_middleware(
|
self.__application.add_middleware(
|
||||||
AuthenticationMiddleware,
|
AuthenticationMiddleware,
|
||||||
backend=JWTAuthenticationBackend(secret_key=SECRET)
|
backend=JWTAuthenticationBackend(secret_key=SECRET)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not PRODUCTION:
|
if not PRODUCTION:
|
||||||
self.application.add_middleware(
|
self.__application.add_middleware(
|
||||||
TimingMiddleware,
|
TimingMiddleware,
|
||||||
client=HTimingClient(),
|
client=HTimingClient(),
|
||||||
metric_namer=StarletteScopeToName(prefix="halfapi",
|
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):
|
async def version_async(self, request, *args, **kwargs):
|
||||||
return Response(self.version)
|
return Response(self.version)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def application(self):
|
||||||
|
return self.__application
|
||||||
|
|
||||||
def routes(self):
|
def routes(self):
|
||||||
""" Halfapi default routes
|
""" Halfapi default routes
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user