Reworks REST API to return i18n success/error messages

Implements #4300
This commit is contained in:
Simone Mainardi 2020-08-17 19:18:13 +02:00
parent 398e25c022
commit 16db3cda67
34 changed files with 175 additions and 171 deletions

View file

@ -20,7 +20,7 @@ local rest_utils = require("rest_utils")
sendHTTPContentTypeHeader('application/json')
local rc = rest_utils.consts_ok
local rc = rest_utils.consts.success.ok
local res = {}
local ifid = _GET["ifid"]
@ -48,7 +48,7 @@ local mac = _GET["mac"]
local top_hidden = ternary(_GET["top_hidden"] == "1", true, nil)
if isEmptyString(ifid) then
rc = rest_utils.consts_invalid_interface
rc = rest_utils.consts.err.invalid_interface
print(rest_utils.rc(rc))
return
end
@ -122,14 +122,14 @@ local hosts_stats = hosts_retrv_function(false, sortColumn, perPage, to_skip, sO
filtered_hosts, blacklisted_hosts, top_hidden, anomalous, dhcp_hosts, cidr)
if hosts_stats == nil then
print(rest_utils.rc(rest_utils.consts_not_found))
print(rest_utils.rc(rest_utils.consts.err.not_found))
return
end
hosts_stats = hosts_stats["hosts"]
if hosts_stats == nil then
print(rest_utils.rc(rest_utils.consts_internal_error))
print(rest_utils.rc(rest_utils.consts.err.internal_error))
return
end