Rename make_json_response -> json_response.

master
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
1 changed files with 4 additions and 2 deletions

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