Implements REST API endpoint to read the API version

This commit is contained in:
Simone Mainardi 2021-07-30 10:18:19 +02:00
parent 205e2cb1bd
commit 920e86f261
2 changed files with 50 additions and 1 deletions

View file

@ -0,0 +1,30 @@
--
-- (C) 2013-21 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
local json = require "dkjson"
local rest_utils = require "rest_utils"
--
-- Return all the supported REST API versions and the current REST API version used by ntopng
-- Example: curl -u admin:admin -H "Content-Type: application/json" http://localhost:3000/lua/rest/version.lua
--
-- NOTE: in case of invalid login, no error is returned but redirected to login
--
local rc = rest_utils.consts.success.ok
local res = {
-- An array of all the supported REST API versions
supported_versions = {
{ version = "1", root = string.format("%s/rest/v1", ntop.getHttpPrefix())},
{ version = "2", root = string.format("%s/rest/v2", ntop.getHttpPrefix())},
},
-- Current REST API version used by ntopng
current_version = "2"
}
rest_utils.answer(rc, res)