api_server: return JSON format if 403 occurred

This commit is contained in:
debugtalk
2017-06-30 12:01:17 +08:00
parent c3ce0c53fd
commit 7de283233e

View File

@@ -41,7 +41,13 @@ def validate_request(func):
assert authorization == req_authorization
return func(*args, **kwds)
except (KeyError, AssertionError):
return "Authorization failed!", 403
result = {
'success': False,
'msg': "Authorization failed!"
}
response = make_response(json.dumps(result), 403)
response.headers["Content-Type"] = "application/json"
return response
return wrapper