$ luarocks install lua-resty-libr3
-- r3 router
local r3 = require("resty.r3").new();
local encode_json = require("cjson.safe").encode
function foo(params) -- foo handler
ngx.say("foo: ", encode_json(params))
end
-- routing
r3:get("/foo/{id}/{name}", foo)
-- don't forget!!!
r3:compile()
-- dispatch
local ok = r3:dispatch("/foo/a/b", ngx.req.get_method())
if not ok then
ngx.exit(404)
end