diff --git a/halfapi/lib/domain_middleware.py b/halfapi/lib/domain_middleware.py index 448535d..46fccc4 100644 --- a/halfapi/lib/domain_middleware.py +++ b/halfapi/lib/domain_middleware.py @@ -81,4 +81,13 @@ class DomainMiddleware(BaseHTTPMiddleware): # Set the http header "x-acl" if an acl was used on the route 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 diff --git a/halfapi/lib/routes.py b/halfapi/lib/routes.py index 0c0be13..d2fa21a 100644 --- a/halfapi/lib/routes.py +++ b/halfapi/lib/routes.py @@ -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")})') req.scope['acl_pass'] = param['acl'].__name__ + if 'args' in param: + req.scope['args'] = param['args'] if 'check' in req.query_params: return PlainTextResponse(param['acl'].__name__)