jbe@216: --[[-- jbe@216: route = jbe@216: request.default_router( jbe@216: path -- URL path, including a leading slash jbe@216: ) jbe@210: jbe@216: Default conversion from a path to a route. Called by request.router(). jbe@216: jbe@216: --]]-- jbe@215: jbe@215: function request.default_router(path) jbe@216: if not path then jbe@216: return nil jbe@216: end jbe@216: if not string.match(path, "^/") then jbe@216: path = "/" .. path jbe@216: end jbe@216: if path == "/" then jbe@216: return {module = "index", view = "index"} jbe@216: end jbe@216: module = string.match(path, "^/([^/]+)/$") jbe@216: if module then jbe@216: return {module = module, view = "index"} jbe@215: end jbe@216: module, action = string.match(path, "^/([^/]+)/([^/.]+)$") jbe@216: if module then jbe@216: return {module = module, action = action} jbe@215: end jbe@216: module, view, suffix = string.match(path, "^/([^/]+)/([^/.]+)%.([^/]+)$") jbe@216: if module then jbe@216: return {module = module, view = view, suffix = suffix} jbe@216: end jbe@216: module, view, id, suffix = string.match(path, "^/([^/]+)/([^/]+)/([^/.]+)%.([^/]+)$") jbe@216: if module then jbe@216: return {module = module, view = view, id = id, suffix = suffix} jbe@216: end jbe@216: return nil jbe@216: end jbe@210: jbe@216: --//--