From 711af2a03ecf13a92396015b2e5547168d309901 Mon Sep 17 00:00:00 2001 From: Yusheng Li Date: Wed, 3 Jan 2024 22:13:29 +0800 Subject: [PATCH] add radix-router-0.2.0-1.rockspec (#16) --- rockspecs/radix-router-0.2.0-1.rockspec | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 rockspecs/radix-router-0.2.0-1.rockspec diff --git a/rockspecs/radix-router-0.2.0-1.rockspec b/rockspecs/radix-router-0.2.0-1.rockspec new file mode 100644 index 0000000..479ef7b --- /dev/null +++ b/rockspecs/radix-router-0.2.0-1.rockspec @@ -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", + }, +} \ No newline at end of file