mod_audit: make the extension of the module API less of a hack
Thanks, Zash, for making me look at mod_http.
--- a/mod_audit/mod_audit.lua Tue Apr 26 22:37:13 2022 +0200
+++ b/mod_audit/mod_audit.lua Tue Apr 26 22:42:09 2022 +0200
@@ -2,6 +2,7 @@
local time_now = os.time;
local st = require "util.stanza";
+local moduleapi = require "core.moduleapi";
local host_wide_user = "@";
@@ -77,10 +78,8 @@
end
end
-local module_api = getmetatable(module).__index;
-
-function module_api:audit(user, event_type, extra)
- audit(self.host, user, "mod_" .. self:get_name(), event_type, extra);
+function moduleapi.audit(module, user, event_type, extra)
+ audit(module.host, user, "mod_" .. module:get_name(), event_type, extra);
end
module:hook("audit", audit, 0);