allowed passing arguments to json response encoder

This commit is contained in:
ctlaltdefeat 2017-01-21 22:40:34 +02:00
parent 28396c8620
commit a811c84e99

View File

@ -142,14 +142,15 @@ class HTTPResponse:
return self._cookies
def json(body, status=200, headers=None):
def json(body, status=200, headers=None, **kwargs):
"""
Returns response object with body in json format.
:param body: Response data to be serialized.
:param status: Response code.
:param headers: Custom Headers.
:param \**kwargs: Remaining arguments that are passed to the json encoder.
"""
return HTTPResponse(json_dumps(body), headers=headers, status=status,
return HTTPResponse(json_dumps(body, **kwargs), headers=headers, status=status,
content_type="application/json")