Rename make_json_response -> json_response.

This commit is contained in:
voussoir 2021-10-01 23:01:36 -07:00
parent aa1e2d5756
commit 129eb3f8aa
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -143,12 +143,14 @@ def gzip_response(request, response):
return response
def make_json_response(j, *args, **kwargs):
def json_response(j, *args, **kwargs):
dumped = json.dumps(j)
response = flask.Response(dumped, *args, **kwargs)
response.headers['Content-Type'] = 'application/json;charset=utf-8'
return response
make_json_response = json_response
def required_fields(fields, forbid_whitespace=False):
'''
Declare that the endpoint requires certain POST body fields. Without them,
@ -172,7 +174,7 @@ def required_fields(fields, forbid_whitespace=False):
'error_type': 'MISSING_FIELDS',
'error_message': 'Required fields: %s' % ', '.join(fields),
}
response = make_json_response(response, status=400)
response = json_response(response, status=400)
return response
return function(*args, **kwargs)
return wrapped