Ajout du header http "x-acl" qui renseigne l'acl qui a passé dans une requête
This commit is contained in:
parent
4eb23fd189
commit
b5ef4a12d1
|
@ -32,6 +32,7 @@ class DomainMiddleware(BaseHTTPMiddleware):
|
||||||
self.domains = {}
|
self.domains = {}
|
||||||
self.api = {}
|
self.api = {}
|
||||||
self.acl = {}
|
self.acl = {}
|
||||||
|
self.request = None
|
||||||
|
|
||||||
|
|
||||||
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
||||||
|
@ -63,13 +64,21 @@ class DomainMiddleware(BaseHTTPMiddleware):
|
||||||
scope_['config'] = {}
|
scope_['config'] = {}
|
||||||
|
|
||||||
|
|
||||||
request = Request(scope_, receive)
|
self.request = Request(scope_, receive)
|
||||||
response = await self.dispatch(request, self.call_next)
|
response = await self.dispatch(self.request, self.call_next)
|
||||||
await response(scope_, receive, send)
|
await response(scope_, receive, send)
|
||||||
|
|
||||||
|
|
||||||
async def dispatch(self, request: Request,
|
async def dispatch(self, request: Request,
|
||||||
call_next: RequestResponseEndpoint) -> Response:
|
call_next: RequestResponseEndpoint) -> Response:
|
||||||
|
"""
|
||||||
|
Call of the route fonction (decorated or not)
|
||||||
|
"""
|
||||||
|
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
|
|
||||||
|
if 'acl_pass' in self.request.scope:
|
||||||
|
# Set the http header "x-acl" if an acl was used on the route
|
||||||
|
response.headers['x-acl'] = self.request.scope['acl_pass']
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in New Issue