mod_audit: make the extension of the module API less of a hack
authorJonas Schäfer <jonas@wielicki.name>
Tue, 26 Apr 2022 22:42:09 +0200
changeset 4938 ae83200fb55f
parent 4937 08dea42a302a
child 4939 a85efae90e21
mod_audit: make the extension of the module API less of a hack Thanks, Zash, for making me look at mod_http.
mod_audit/mod_audit.lua
--- 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);