def json_response(func):
    """
    @json_response decorator adds response header for content type,
    and json-dumps response object.

    Example usage:

        @json_response
        def test(request):
            return { "hello": "world" }
    """

    @wraps(func)
    def wrapper(request, *args, **kwargs):
        res = func(request, *args, **kwargs)
        request.setHeader('Content-Type', 'application/json')
        return json.dumps(res)

    return wrapper