From e56e442d6af125522214a9bc9ab957ac39c5c0c8 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 15 Apr 2020 22:25:48 +0200 Subject: luci-base: implement JSON endpoint to fetch menu information Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/controller/admin/index.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'modules/luci-base/luasrc/controller/admin/index.lua') diff --git a/modules/luci-base/luasrc/controller/admin/index.lua b/modules/luci-base/luasrc/controller/admin/index.lua index 68bbd38a71..736d0cdccf 100644 --- a/modules/luci-base/luasrc/controller/admin/index.lua +++ b/modules/luci-base/luasrc/controller/admin/index.lua @@ -182,3 +182,15 @@ function action_ubus() luci.http.prepare_content("application/json") luci.http.write_json(response) end + +function action_menu() + local dsp = require "luci.dispatcher" + local utl = require "luci.util" + local http = require "luci.http" + + local acls = utl.ubus("session", "access", { ubus_rpc_session = http.getcookie("sysauth") }) + local menu = dsp.menu_json(acls or {}) or {} + + http.prepare_content("application/json") + http.write_json(menu) +end -- cgit v1.2.3