* libs/web: Added .leaf attribute to dispatching tree to stop dispatching at a certai...
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index d075975..d1fcdcd 100644 (file)
@@ -80,7 +80,7 @@ function httpdispatch()
        local pathinfo = luci.http.env.PATH_INFO or ""
        local c = tree
 
-       for s in pathinfo:gmatch("([%w_]+)") do
+       for s in pathinfo:gmatch("([%w-]+)") do
                table.insert(request, s)
        end
 
@@ -98,7 +98,7 @@ function dispatch()
 
        for i, s in ipairs(request) do
                c = c.nodes[s]
-               if not c then
+               if not c or c.leaf then
                        break
                end
 
@@ -282,6 +282,21 @@ function alias(...)
        end
 end
 
+function rewrite(n, ...)
+       local req = arg
+       return function()
+               for i=1,n do 
+                       table.remove(request, 1)
+               end
+               
+               for i,r in ipairs(req) do
+                       table.insert(request, i, r)
+               end
+               
+               dispatch()
+       end
+end
+
 function call(name)
        return function() getfenv()[name]() end
 end