mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +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
|
|
@ -17,8 +17,6 @@ local rest_utils = require("rest_utils")
|
|||
-- NOTE: in case of invalid login, no error is returned but redirected to login
|
||||
--
|
||||
|
||||
sendHTTPHeader('application/json')
|
||||
|
||||
local rc = rest_utils.consts.success.ok
|
||||
local res = {}
|
||||
|
||||
|
|
@ -26,12 +24,12 @@ local host_info = url2hostinfo(_POST)
|
|||
local custom_name = _POST["custom_name"]
|
||||
|
||||
if not haveAdminPrivileges() then
|
||||
print(rest_utils.rc(rest_utils.consts.err.not_granted))
|
||||
rest_utils.answer(rest_utils.consts.err.not_granted)
|
||||
return
|
||||
end
|
||||
|
||||
if host_info == nil or isEmptyString(host_info["host"]) or custom_name == nil then
|
||||
print(rest_utils.rc(rest_utils.consts.err.invalid_args))
|
||||
rest_utils.answer(rest_utils.consts.err.invalid_args)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -40,5 +38,5 @@ setHostAltName(host_info["host"], custom_name)
|
|||
-- TRACKER HOOK
|
||||
tracker.log('set_host_alias', { host = hostinfo2hostkey(host_info), custom_name = custom_name })
|
||||
|
||||
print(rest_utils.rc(rc, res))
|
||||
rest_utils.answer(rc, res)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue