require("luci.sys")
require("luci.fs")
--- Dirty OpenWRT fix
-if (os.time() < 1000000000) then
- os.execute('date -s '..os.date('%m%d%H%M%Y', luci.fs.mtime(luci.sys.libpath() .. "/dispatcher.lua"))..' > /dev/null 2>&1')
-end
-
context = luci.util.threadlocal()
-- Index table
function httpdispatch(request)
luci.http.context.request = request
context.request = {}
- local pathinfo = request.env.PATH_INFO or ""
+ local pathinfo = request:getenv("PATH_INFO") or ""
for node in pathinfo:gmatch("[^/]+") do
table.insert(context.request, node)
luci.i18n.loadc("default")
local scope = luci.util.clone(_G)
- for k,v in pairs(_M) do
+ for k,v in pairs(luci.dispatcher) do
if type(v) == "function" then
scope[k] = v
end
for k, v in pairs(index) do
scope._NAME = k
setfenv(v, scope)
-
+
local stat, err = luci.util.copcall(v)
if not stat then
- error500(err)
+ error500("createtree failed: " .. k .. ": " .. err)
os.exit(1)
end
end