ajout du header x-args-required et x-args-optional
This commit is contained in:
parent
b5ef4a12d1
commit
89ec439d3e
|
@ -81,4 +81,13 @@ class DomainMiddleware(BaseHTTPMiddleware):
|
||||||
# Set the http header "x-acl" if an acl was used on the route
|
# Set the http header "x-acl" if an acl was used on the route
|
||||||
response.headers['x-acl'] = self.request.scope['acl_pass']
|
response.headers['x-acl'] = self.request.scope['acl_pass']
|
||||||
|
|
||||||
|
if 'args' in self.request.scope:
|
||||||
|
# Set the http headers "x-args-required" and "x-args-optional"
|
||||||
|
|
||||||
|
if 'required' in self.request.scope['args']:
|
||||||
|
response.headers['x-args-required'] = \
|
||||||
|
','.join(self.request.scope['args']['required'])
|
||||||
|
if 'optional' in self.request.scope['args']:
|
||||||
|
response.headers['x-args-optional'] = \
|
||||||
|
','.join(self.request.scope['args']['optional'])
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -51,6 +51,8 @@ def route_acl_decorator(fct: Callable, params: List[Dict]):
|
||||||
logger.debug(f'ACL OK for current route ({fct} - {param.get("acl")})')
|
logger.debug(f'ACL OK for current route ({fct} - {param.get("acl")})')
|
||||||
|
|
||||||
req.scope['acl_pass'] = param['acl'].__name__
|
req.scope['acl_pass'] = param['acl'].__name__
|
||||||
|
if 'args' in param:
|
||||||
|
req.scope['args'] = param['args']
|
||||||
|
|
||||||
if 'check' in req.query_params:
|
if 'check' in req.query_params:
|
||||||
return PlainTextResponse(param['acl'].__name__)
|
return PlainTextResponse(param['acl'].__name__)
|
||||||
|
|
Loading…
Reference in New Issue