webmcp
view framework/env/request/default_router.lua @ 404:b42a6c9cc322
Fixed syntax error in autodoc documentation of mondelefant.connect{...}
| author | jbe | 
|---|---|
| date | Wed Jan 06 02:53:14 2016 +0100 (2016-01-06) | 
| parents | 545ec2e3eafa | 
| children | 32b79658e5ae | 
 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   if path == "" then
    16     return {module = "index", view = "index"}
    17   end
    18   local static = string.match(path, "^static/([-./0-9A-Z_a-z]*)$")
    19   if static then
    20     -- Note: sanitizer is in request.handler(...)
    21     return {static = static}
    22   end
    23   local module, action, view, id, suffix
    24   module = string.match(path, "^([^/]+)/$")
    25   if module then
    26     return {module = module, view = "index"}
    27   end
    28   module, action = string.match(path, "^([^/]+)/([^/.]+)$")
    29   if module then
    30     return {module = module, action = action}
    31   end
    32   module, view, suffix = string.match(path, "^([^/]+)/([^/.]+)%.([^/]+)$")
    33   if module then
    34     return {module = module, view = view, suffix = suffix}
    35   end
    36   module, view, id, suffix = string.match(path, "^([^/]+)/([^/]+)/([^/.]+)%.([^/]+)$")
    37   if module then
    38     return {module = module, view = view, id = id, suffix = suffix}
    39   end
    40   return nil
    41 end
    43 --//--
