mod_http: Use hostname from the correct context (thanks gryffus)
[prosody.git] / core / moduleapi.lua
index 9baf4fbaa4549e03d8edf2a8f7b575fb93ad8521..ed75669b60b64f6c90e5c19f9ee843328f20ec55 100644 (file)
@@ -319,7 +319,13 @@ function api:handle_items(type, added_cb, removed_cb, existing)
 end
 
 function api:provides(name, item)
-       if not item then item = self.environment; end
+       -- if not item then item = setmetatable({}, { __index = function(t,k) return rawget(self.environment, k); end }); end
+       if not item then
+               item = {}
+               for k,v in pairs(self.environment) do
+                       if k ~= "module" then item[k] = v; end
+               end
+       end
        if not item.name then
                local item_name = self.name;
                -- Strip a provider prefix to find the item name
@@ -329,6 +335,7 @@ function api:provides(name, item)
                end
                item.name = item_name;
        end
+       item._provided_by = self.name;
        self:add_item(name.."-provider", item);
 end