-
Notifications
You must be signed in to change notification settings - Fork 11
/
radix-router-dev-1.rockspec
73 lines (66 loc) · 2.2 KB
/
radix-router-dev-1.rockspec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package = "radix-router"
version = "dev-1"
source = {
url = "git+https://github.com/vm-001/lua-radix-router.git",
branch = "main"
}
description = {
summary = "Fast API Router for Lua/LuaJIT",
detailed = [[
A lightweight high-performance and radix tree based router for Lua/LuaJIT/OpenResty.
local Router = require "radix-router"
local router, err = Router.new({
{ -- static path
paths = { "/foo", "/foo/bar", "/html/index.html" },
handler = "1" -- handler can be any non-nil value. (e.g. boolean, table, function)
},
{ -- variable path
paths = { "/users/{id}/profile-{year}.{format}" },
handler = "2"
},
{ -- prefix path
paths = { "/api/authn/{*path}" },
handler = "3"
},
{ -- methods condition
paths = { "/users/{id}" },
methods = { "POST" },
handler = "4"
}
})
if not router then
error("failed to create router: " .. err)
end
assert("1" == router:match("/html/index.html"))
assert("2" == router:match("/users/100/profile-2023.pdf"))
assert("3" == router:match("/api/authn/token/genreate"))
assert("4" == router:match("/users/100", { method = "POST" }))
-- variable binding
local params = {}
router:match("/users/100/profile-2023.pdf", nil, params)
assert(params.year == "2023")
assert(params.format == "pdf")
]],
homepage = "https://github.com/vm-001/lua-radix-router",
license = "BSD-2-Clause license"
}
dependencies = {
"lrexlib-pcre2",
}
build = {
type = "builtin",
modules = {
["radix-router"] = "src/router.lua",
["radix-router.options"] = "src/options.lua",
["radix-router.route"] = "src/route.lua",
["radix-router.trie"] = "src/trie.lua",
["radix-router.utils"] = "src/utils.lua",
["radix-router.constants"] = "src/constants.lua",
["radix-router.iterator"] = "src/iterator.lua",
["radix-router.parser"] = "src/parser/parser.lua",
["radix-router.parser.style.default"] = "src/parser/style/default.lua",
["radix-router.matcher"] = "src/matcher/matcher.lua",
["radix-router.matcher.host"] = "src/matcher/host.lua",
["radix-router.matcher.method"] = "src/matcher/method.lua",
},
}