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, require, tostring, type = ipairs, require, tostring, type
15 local file = require "luci.lucid.http.handler.file"
16 local srv = require "luci.lucid.http.server"
18 module "luci.lucid.http.DirectoryPublisher"
21 function factory(server, config)
22 config.domain = config.domain or ""
23 local vhost = server:get_vhosts()[config.domain]
26 server:set_vhost(config.domain, vhost)
29 local handler = file.Simple(config.name, config.physical, config)
31 for _, r in ipairs(config.read) do
32 if r:sub(1,1) == ":" then
33 handler:restrict({interface = r:sub(2)})
35 handler:restrict({user = r})
40 if type(config.virtual) == "table" then
41 for _, v in ipairs(config.virtual) do
42 vhost:set_handler(v, handler)
45 vhost:set_handler(config.virtual, handler)