mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
REST endpoints now return specific HTTP codes on failure (fix #4278)
This commit is contained in:
parent
745b3b52d3
commit
ba2e44ddc6
37 changed files with 141 additions and 228 deletions
|
|
@ -29,22 +29,19 @@ local ifid = _GET["ifid"]
|
|||
local download = _GET["download"]
|
||||
|
||||
if not haveAdminPrivileges() then
|
||||
sendHTTPHeader('application/json')
|
||||
print(rest_utils.rc(rest_utils.consts.err.not_granted))
|
||||
rest_utils.answer(rest_utils.consts.err.not_granted)
|
||||
return
|
||||
end
|
||||
|
||||
if isEmptyString(ifid) then
|
||||
sendHTTPHeader('application/json')
|
||||
print(rest_utils.rc(rest_utils.consts.err.invalid_interface))
|
||||
rest_utils.answer(rest_utils.consts.err.invalid_interface)
|
||||
return
|
||||
end
|
||||
|
||||
local res = host_pools_nedge.export()
|
||||
|
||||
if isEmptyString(download) then
|
||||
sendHTTPHeader('application/json')
|
||||
print(rest_utils.rc(rc, res))
|
||||
rest_utils.answer(rc, res)
|
||||
else
|
||||
sendHTTPContentTypeHeader('application/json', 'attachment; filename="pools_configuration.json"')
|
||||
print(json.encode(res, nil))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue