INNER CODE UNIT · Python
my_serializer
falconry/falcon · falcon/app.py:1059
def my_serializer(
req: Request, resp: Response, exception: HTTPError
) -> None:
representation = None
preferred = req.client_prefers((falcon.MEDIA_YAML, falcon.MEDIA_JSON))
if preferred is not None:
if preferred == falcon.MEDIA_JSON:
resp.data = exception.to_json()
else:
resp.text = yaml.dump(exception.to_dict(), encoding=None)
resp.content_type = preferred
resp.append_header('Vary', 'Accept')
Args:
serializer (callable): A function taking the form