mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 04:10:21 +08:00
api_server: return JSON format if 403 occurred
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user