Merge pull request #331 from ctlaltdefeat/json-response-args

allowed passing arguments to json response encoder
This commit is contained in:
Eli Uriegas 2017-01-21 15:31:57 -06:00 committed by GitHub
commit 6f4f2758d6

View File

@ -142,15 +142,16 @@ class HTTPResponse:
return self._cookies 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. Returns response object with body in json format.
:param body: Response data to be serialized. :param body: Response data to be serialized.
:param status: Response code. :param status: Response code.
:param headers: Custom Headers. :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,
content_type="application/json") status=status, content_type="application/json")
def text(body, status=200, headers=None): def text(body, status=200, headers=None):