REST endpoints now return specific HTTP codes on failure (fix #4278)

This commit is contained in:
Alfredo Cardigliano 2020-08-20 11:45:17 +02:00
parent 745b3b52d3
commit ba2e44ddc6
37 changed files with 141 additions and 228 deletions

View file

@ -20,11 +20,9 @@ local rest_utils = require("rest_utils")
-- NOTE: in case of invalid login, no error is returned but redirected to login
--
sendHTTPHeader('application/json')
if not isAllowedSystemInterface() then
rc = rest_utils.consts.err.not_granted
print(rest_utils.rc(rc))
rest_utils.answer(rc)
return
end
@ -33,4 +31,4 @@ local res = system_utils.systemHostStats()
res.epoch = os.time()
res.storage = storage_utils.storageInfo()
print(rest_utils.rc(rc, res))
rest_utils.answer(rc, res)