Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if request.matched_route is not None:
# do some sanity checking on the response using filters
services = request.registry.cornice_services
pattern = request.matched_route.pattern
service = services.get(pattern, None)
if service is not None:
kwargs, ob = getattr(request, "cornice_args", ({}, None))
for _filter in kwargs.get('filters', []):
if is_string(_filter) and ob is not None:
_filter = getattr(ob, _filter)
try:
response = _filter(response, request)
except TypeError:
response = _filter(response)
if service.cors_enabled:
apply_cors_post_request(service, request, response)
return response