3 (c) 2009 Steven Barth <steven@midlink.org>
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
14 local ipairs, pcall, type = ipairs, pcall, type
15 local luci = require "luci.lucid.http.handler.luci"
16 local srv = require "luci.lucid.http.server"
19 module "luci.lucid.http.LuciWebPublisher"
22 --- Prepare a LuCI web publisher and assign it to a given Virtual Host.
23 -- @param server HTTP daemon object
24 -- @param config publisher configuration
25 function factory(server, config)
27 require "luci.dispatcher"
31 config.domain = config.domain or ""
32 local vhost = server:get_vhosts()[config.domain]
35 server:set_vhost(config.domain, vhost)
39 if config.physical and #config.physical > 0 then
41 for k in config.physical:gmatch("[^/]+") do
48 local handler = luci.Luci(config.name, prefix)
50 for _, r in ipairs(config.exec) do
51 if r:sub(1,1) == ":" then
52 handler:restrict({interface = r:sub(2)})
54 handler:restrict({user = r})
60 if type(config.virtual) == "table" then
61 for _, v in ipairs(config.virtual) do
63 vhost:set_handler(v, handler)
66 mypath = config.virtual
67 vhost:set_handler(config.virtual or "", handler)
71 vhost.default = mypath