mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Add support for returning HTTP status codes to rest_utils
This commit is contained in:
parent
5f3c83ff45
commit
646c5a8d68
3 changed files with 79 additions and 45 deletions
|
|
@ -16,15 +16,13 @@ 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 = {}
|
||||
|
||||
local hostname = _GET["hostname"]
|
||||
|
||||
if isEmptyString(hostname) then
|
||||
print(rest_utils.rc(rest_utils.consts.err.invalid_args))
|
||||
rest_utils.answer(rest_utils.consts.err.invalid_args)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -34,10 +32,10 @@ if not resolved then
|
|||
end
|
||||
|
||||
if not resolved then
|
||||
print(rest_utils.rc(rest_utils.consts.err.resolution_failed))
|
||||
rest_utils.answer(rest_utils.consts.err.resolution_failed)
|
||||
return
|
||||
end
|
||||
|
||||
res = resolved
|
||||
|
||||
print(rest_utils.rc(rc, res))
|
||||
rest_utils.answer(rc, res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue