aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/actions.lua19
-rw-r--r--core/modulemanager.lua15
2 files changed, 33 insertions, 1 deletions
diff --git a/core/actions.lua b/core/actions.lua
new file mode 100644
index 00000000..d0be5aeb
--- /dev/null
+++ b/core/actions.lua
@@ -0,0 +1,19 @@
+
+local actions = {};
+
+function register(path, t)
+ local curr = actions;
+ for comp in path:gmatch("([^/]+)/") do
+ if curr[comp] == nil then
+ curr[comp] = {};
+ end
+ curr = curr[comp];
+ if type(curr) ~= "table" then
+ return nil, "path-taken";
+ end
+ end
+ curr[path:match("/([^/]+)$")] = t;
+ return true;
+end
+
+return { actions = actions, register= register }; \ No newline at end of file
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 3481aac6..6ef39e82 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -27,7 +27,7 @@ local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler;
local eventmanager = require "core.eventmanager";
local config = require "core.configmanager";
local multitable_new = require "util.multitable".new;
-
+local register_actions = require "core.actions".register;
local loadfile, pcall = loadfile, pcall;
local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv;
@@ -254,4 +254,17 @@ end
--------------------------------------------------------------------
+local actions = {};
+
+function actions.load(params)
+ --return true, "Module loaded ("..params.module.." on "..params.host..")";
+ return load(params.host, params.module);
+end
+
+function actions.unload(params)
+ return unload(params.host, params.module);
+end
+
+register_actions("/modules", actions);
+
return _M;