mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Reworks REST API to return i18n success/error messages
Implements #4300
This commit is contained in:
parent
398e25c022
commit
16db3cda67
34 changed files with 175 additions and 171 deletions
|
|
@ -27,7 +27,7 @@ sendHTTPHeader('application/json')
|
|||
local ifid = _GET["ifid"]
|
||||
|
||||
if not haveAdminPrivileges() then
|
||||
print(rest_utils.rc(rest_utils.consts_not_granted))
|
||||
print(rest_utils.rc(rest_utils.consts.err.not_granted))
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -36,24 +36,24 @@ if isEmptyString(ifid) then
|
|||
end
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
print(rest_utils.rc(rest_utils.consts_invalid_interface))
|
||||
print(rest_utils.rc(rest_utils.consts.err.invalid_interface))
|
||||
return
|
||||
end
|
||||
|
||||
if(_POST["JSON"] == nil) then
|
||||
print(rest_utils.rc(rest_utils.consts_invalid_args))
|
||||
print(rest_utils.rc(rest_utils.consts.err.invalid_args))
|
||||
return
|
||||
end
|
||||
|
||||
local data = json.decode(_POST["JSON"])
|
||||
|
||||
if(table.empty(data)) then
|
||||
print(rest_utils.rc(rest_utils.consts_bad_format))
|
||||
print(rest_utils.rc(rest_utils.consts.err.bad_format))
|
||||
return
|
||||
end
|
||||
|
||||
if data["0"] == nil then
|
||||
print(rest_utils.rc(rest_utils.consts_bad_content))
|
||||
print(rest_utils.rc(rest_utils.consts.err.bad_content))
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ local success = host_pools_nedge.import(data)
|
|||
ntop.reloadHostPools()
|
||||
|
||||
if not success then
|
||||
print(rest_utils.rc(rest_utils.consts_internal_error))
|
||||
print(rest_utils.rc(rest_utils.consts.err.internal_error))
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -73,4 +73,4 @@ end
|
|||
-- TRACKER HOOK
|
||||
tracker.log('set_pool_config', {})
|
||||
|
||||
print(rest_utils.rc(rest_utils.consts_ok))
|
||||
print(rest_utils.rc(rest_utils.consts.success.ok))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue