-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add radix-router-0.2.0-1.rockspec (#16)
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package = "radix-router" | ||
version = "0.2.0-1" | ||
|
||
source = { | ||
url = "git://github.com/vm-001/lua-radix-router", | ||
tag = "v0.2.0", | ||
} | ||
|
||
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 = { | ||
"lua >= 5.1, < 5.5" | ||
} | ||
|
||
build = { | ||
type = "builtin", | ||
modules = { | ||
["radix-router"] = "src/router.lua", | ||
["radix-router.route"] = "src/route.lua", | ||
["radix-router.trie"] = "src/trie.lua", | ||
["radix-router.utils"] = "src/utils.lua", | ||
["radix-router.constatns"] = "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", | ||
}, | ||
} |