libs/lucid-http: fix regressions with recent git uci
[project/luci.git] / libs / lucid-http / luasrc / lucid / http / LuciWebPublisher.lua
index 0d06489..5dc70df 100644 (file)
@@ -18,6 +18,10 @@ local srv = require "luci.lucid.http.server"
 
 module "luci.lucid.http.LuciWebPublisher"
 
+
+--- Prepare a LuCI web publisher and assign it to a given Virtual Host.
+-- @param server HTTP daemon object
+-- @param config publisher configuration
 function factory(server, config)
        pcall(function()
                require "luci.dispatcher"
@@ -52,11 +56,18 @@ function factory(server, config)
                end
        end
 
+       local mypath
        if type(config.virtual) == "table" then
                for _, v in ipairs(config.virtual) do
+                       mypath = mypath or v
                        vhost:set_handler(v, handler)
                end
        else
-               vhost:set_handler(config.virtual, handler)
+               mypath = config.virtual
+               vhost:set_handler(config.virtual or "", handler)
+       end
+
+       if config.home then
+               vhost.default = mypath
        end
-end
\ No newline at end of file
+end