[lib/domain_middleware] takes full domain config in constructor

This commit is contained in:
Maxime Alves LIRMM@home 2022-08-08 20:16:03 +02:00
parent 782a489042
commit bc37b2c4b7
2 changed files with 7 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class HalfDomain(Starlette):
'id': self.id, 'id': self.id,
'version': self.version, 'version': self.version,
'halfapi_version': self.halfapi_version, 'halfapi_version': self.halfapi_version,
'config': self.config.get('domain', {}).get(self.name, {}).get('config', {}) 'config': self.config['domain'][self.name]
} }
}) })
] ]

View File

@ -22,10 +22,15 @@ class DomainMiddleware(BaseHTTPMiddleware):
""" """
logger.info('DomainMiddleware app:%s domain:%s', app, domain) logger.info('DomainMiddleware app:%s domain:%s', app, domain)
super().__init__(app) super().__init__(app)
self.domain = domain self.domain = domain.copy()
self.name = domain['name']
self.request = None self.request = None
@property
def config(self):
return { **self.domain['config'] }
async def dispatch(self, request: Request, async def dispatch(self, request: Request,
call_next: RequestResponseEndpoint) -> Response: call_next: RequestResponseEndpoint) -> Response:
""" """