webmcp
view framework/env/request/default_router.lua @ 236:4ab91adeab6f
Added local variable declarations in request/default_router.lua
| author | jbe | 
|---|---|
| date | Sat Feb 28 23:37:27 2015 +0100 (2015-02-28) | 
| parents | 25a20bd1f416 | 
| children | db79324a13fe | 
 line source
     1 --[[--
     2 route =
     3 request.default_router(
     4   path                   -- URL path, including a leading slash
     5 )
     7 Default conversion from a path to a route. Called by request.router().
     9 --]]--
    11 function request.default_router(path)
    12   if not path then
    13     return nil
    14   end
    15   local module, action, view, id, suffix
    16   if path == "" then
    17     return {module = "index", view = "index"}
    18   end
    19   module = string.match(path, "^([^/]+)/$")
    20   if module then
    21     return {module = module, view = "index"}
    22   end
    23   module, action = string.match(path, "^([^/]+)/([^/.]+)$")
    24   if module then
    25     return {module = module, action = action}
    26   end
    27   module, view, suffix = string.match(path, "^([^/]+)/([^/.]+)%.([^/]+)$")
    28   if module then
    29     return {module = module, view = view, suffix = suffix}
    30   end
    31   module, view, id, suffix = string.match(path, "^([^/]+)/([^/]+)/([^/.]+)%.([^/]+)$")
    32   if module then
    33     return {module = module, view = view, id = id, suffix = suffix}
    34   end
    35   return nil
    36 end
    38 --//--
