62 lines
1.5 KiB
Lua
62 lines
1.5 KiB
Lua
---
|
||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||
--- Created by admin.
|
||
--- DateTime: 2025/10/28 10:05
|
||
---
|
||
|
||
--解析url路由过滤库
|
||
local radix = require("resty.radixtree")
|
||
--数据表业务处理
|
||
local systemOrganization = require("service.system.organization")
|
||
|
||
--定义相关路由,前端接口url地址
|
||
local routes = {
|
||
--用户相关路由接口
|
||
{
|
||
paths = { "/api/system/organizations" },
|
||
methods = { "GET" },
|
||
handler = systemOrganization.getSystemOrganization,
|
||
},
|
||
{
|
||
paths = { "/api/system/organizations/:id" },
|
||
methods = { "GET" },
|
||
handler = systemOrganization.getSystemOrganization,
|
||
},
|
||
{
|
||
paths = { "/api/system/organizations" },
|
||
methods = { "POST" },
|
||
handler = systemOrganization.addSystemOrganization,
|
||
},
|
||
{
|
||
paths = { "/api/system/organizations/:id" },
|
||
methods = { "DELETE" },
|
||
handler = systemOrganization.deleteSystemOrganization,
|
||
},
|
||
{
|
||
paths = { "/api/system/organizations/:id" },
|
||
methods = { "PUT" },
|
||
handler = systemOrganization.updateSystemOrganization,
|
||
},
|
||
}
|
||
|
||
-- 初始化路由
|
||
local rx, err = radix.new(routes)
|
||
if not rx then
|
||
ngx.say("Not Found")
|
||
ngx.exit(ngx.HTTP_NOT_FOUND)
|
||
end
|
||
|
||
--获取访问的uri地址
|
||
local uri = ngx.var.uri
|
||
local opts = {
|
||
method = ngx.var.request_method,
|
||
matched = {}
|
||
}
|
||
|
||
-- 进行路由匹配和相关函数调用
|
||
local ok = rx:dispatch(uri, opts, opts.matched)
|
||
if not ok then
|
||
ngx.say("Not Found")
|
||
ngx.exit(ngx.HTTP_NOT_FOUND)
|
||
end
|