From bc37b2c4b705b4bfee996c3612005bfae2ab023e Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Mon, 8 Aug 2022 20:16:03 +0200 Subject: [PATCH] [lib/domain_middleware] takes full domain config in constructor --- halfapi/half_domain.py | 2 +- halfapi/lib/domain_middleware.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/halfapi/half_domain.py b/halfapi/half_domain.py index 85309be..035aaa4 100644 --- a/halfapi/half_domain.py +++ b/halfapi/half_domain.py @@ -83,7 +83,7 @@ class HalfDomain(Starlette): 'id': self.id, 'version': self.version, 'halfapi_version': self.halfapi_version, - 'config': self.config.get('domain', {}).get(self.name, {}).get('config', {}) + 'config': self.config['domain'][self.name] } }) ] diff --git a/halfapi/lib/domain_middleware.py b/halfapi/lib/domain_middleware.py index f152dd6..8a37b00 100644 --- a/halfapi/lib/domain_middleware.py +++ b/halfapi/lib/domain_middleware.py @@ -22,10 +22,15 @@ class DomainMiddleware(BaseHTTPMiddleware): """ logger.info('DomainMiddleware app:%s domain:%s', app, domain) super().__init__(app) - self.domain = domain + self.domain = domain.copy() + self.name = domain['name'] self.request = None + @property + def config(self): + return { **self.domain['config'] } + async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response: """