[lib/domain_middleware] takes full domain config in constructor
This commit is contained in:
parent
782a489042
commit
bc37b2c4b7
|
@ -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]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
|
@ -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:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue