webmcp
view framework/env/request/default_router.lua @ 243:d5cba50e16ae
Send "Connection: close" header to terminate process
| author | jbe | 
|---|---|
| date | Sun Mar 01 20:52:03 2015 +0100 (2015-03-01) | 
| parents | 4ab91adeab6f | 
| 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 --//--
