From 17e7f67a7c0bbfa26154005a49faf74b3573ff5d Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Mon, 27 Jul 2009 12:09:46 +0000 Subject: Add native support for homepages --- libs/lucid-http/luasrc/lucid/http/LuciWebPublisher.lua | 7 +++++++ libs/lucid-http/luasrc/lucid/http/server.lua | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'libs/lucid-http/luasrc/lucid') diff --git a/libs/lucid-http/luasrc/lucid/http/LuciWebPublisher.lua b/libs/lucid-http/luasrc/lucid/http/LuciWebPublisher.lua index f72b94f41..92dd7e2cb 100644 --- a/libs/lucid-http/luasrc/lucid/http/LuciWebPublisher.lua +++ b/libs/lucid-http/luasrc/lucid/http/LuciWebPublisher.lua @@ -56,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 + mypath = config.virtual vhost:set_handler(config.virtual, handler) end + + if config.home then + vhost.default = mypath + end end \ No newline at end of file diff --git a/libs/lucid-http/luasrc/lucid/http/server.lua b/libs/lucid-http/luasrc/lucid/http/server.lua index cb10813b9..eb6f6f54f 100644 --- a/libs/lucid-http/luasrc/lucid/http/server.lua +++ b/libs/lucid-http/luasrc/lucid/http/server.lua @@ -198,6 +198,10 @@ function VHost.process(self, request, ...) -- Call URI part request.env.PATH_INFO = uri + if self.default and uri == "/" then + return 302, {Location = self.default} + end + for k, h in pairs(self.handlers) do if #k > hlen then if uri == k or (uri:sub(1, #k) == k and uri:byte(#k+1) == sc) then -- cgit v1.2.3