697:8ddc85fa7602 | 698:d8a678e40a0a |
---|---|
1 | |
2 local actions = {}; | |
3 | |
4 function register(path, t) | |
5 local curr = actions; | |
6 for comp in path:gmatch("([^/]+)/") do | |
7 if curr[comp] == nil then | |
8 curr[comp] = {}; | |
9 end | |
10 curr = curr[comp]; | |
11 if type(curr) ~= "table" then | |
12 return nil, "path-taken"; | |
13 end | |
14 end | |
15 curr[path:match("/([^/]+)$")] = t; | |
16 return true; | |
17 end | |
18 | |
19 return { actions = actions, register= register }; |