summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-15 22:25:48 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-16 13:30:35 +0200
commite56e442d6af125522214a9bc9ab957ac39c5c0c8 (patch)
tree3e4485339f1136a677334131847aabcd611ae33b /modules/luci-base/luasrc
parent51186355ea168dfc6fb1363ace5c57b178f0331e (diff)
luci-base: implement JSON endpoint to fetch menu information
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r--modules/luci-base/luasrc/controller/admin/index.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/controller/admin/index.lua b/modules/luci-base/luasrc/controller/admin/index.lua
index 68bbd38a7..736d0cdcc 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