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