mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-13 00:11:28 +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
|
assert authorization == req_authorization
|
||||||
return func(*args, **kwds)
|
return func(*args, **kwds)
|
||||||
except (KeyError, AssertionError):
|
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
|
return wrapper
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user