* Introducing LuCI HTTPD as testing environment
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index e3ebe5b..6017874 100644 (file)
@@ -84,7 +84,7 @@ end
 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)
@@ -267,7 +267,7 @@ function createtree()
        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
@@ -276,10 +276,10 @@ function createtree()
        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