mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +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
|
|
@ -22,7 +22,7 @@ local rest_utils = require("rest_utils")
|
|||
|
||||
sendHTTPHeader('application/json')
|
||||
|
||||
local rc = rest_utils.consts_ok
|
||||
local rc = rest_utils.consts.success.ok
|
||||
local res = {}
|
||||
|
||||
local ifid = _GET["ifid"]
|
||||
|
|
@ -33,7 +33,7 @@ local alert_type = _GET["alert_type"]
|
|||
local alert_severity = _GET["alert_severity"]
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
rc = rest_utils.consts_invalid_interface
|
||||
rc = rest_utils.consts.err.invalid_interface
|
||||
print(rest_utils.rc(rc))
|
||||
return
|
||||
end
|
||||
|
|
@ -41,13 +41,13 @@ end
|
|||
interface.select(ifid)
|
||||
|
||||
if isEmptyString(what) then
|
||||
rc = rest_utils.consts_invalid_args
|
||||
rc = rest_utils.consts.err.invalid_args
|
||||
print(rest_utils.rc(rc))
|
||||
return
|
||||
end
|
||||
|
||||
if isEmptyString(epoch_begin) or isEmptyString(epoch_end) then
|
||||
rc = rest_utils.consts_invalid_args
|
||||
rc = rest_utils.consts.err.invalid_args
|
||||
print(rest_utils.rc(rc))
|
||||
return
|
||||
end
|
||||
|
|
@ -56,7 +56,7 @@ epoch_begin = tonumber(epoch_begin);
|
|||
epoch_end = tonumber(epoch_end);
|
||||
|
||||
if epoch_end <= epoch_begin then
|
||||
rc = rest_utils.consts_invalid_args
|
||||
rc = rest_utils.consts.err.invalid_args
|
||||
print(rest_utils.rc(rc))
|
||||
return
|
||||
end
|
||||
|
|
@ -80,7 +80,7 @@ end
|
|||
local counters = alert_utils.getNumAlertsPerHour(what, epoch_begin, epoch_end, alert_type, alert_severity)
|
||||
|
||||
if counters == nil then
|
||||
rc = rest_utils.consts_internal_error
|
||||
rc = rest_utils.consts.err.internal_error
|
||||
print(rest_utils.rc(rc))
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue