webmcp

view framework/env/request/default_router.lua @ 221:25a20bd1f416

More work on Moonbridge integration: several changes in env/request
author jbe
date Wed Feb 25 01:33:27 2015 +0100 (2015-02-25)
parents fd0360594636
children 4ab91adeab6f
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 module = string.match(path, "^([^/]+)/$")
19 if module then
20 return {module = module, view = "index"}
21 end
22 module, action = string.match(path, "^([^/]+)/([^/.]+)$")
23 if module then
24 return {module = module, action = action}
25 end
26 module, view, suffix = string.match(path, "^([^/]+)/([^/.]+)%.([^/]+)$")
27 if module then
28 return {module = module, view = view, suffix = suffix}
29 end
30 module, view, id, suffix = string.match(path, "^([^/]+)/([^/]+)/([^/.]+)%.([^/]+)$")
31 if module then
32 return {module = module, view = view, id = id, suffix = suffix}
33 end
34 return nil
35 end
37 --//--

Impressum / About Us