拦截器更改V1.0.1#V1.0.1

This commit is contained in:
xx
2024-06-05 15:53:30 +08:00
parent 247780a33d
commit b7b613b22c
2 changed files with 15 additions and 22 deletions

View File

@@ -1,18 +1,17 @@
require "website"
function access()
if string.sub(request:filepath(),1,12) == "/api/public/" then
--公共开放接口
return true
elseif string.sub(request:filepath(),1,11) == "/api/admin/" then
--管理员目录,需要验证权限
print(param("key"),"\t")
if param("key") == nil or param("key") ~= "123456" then
response:send("key不正确")
return false
end
return true
else
response:send("仅允许访问 /api/public 和 /api/admin 目录")
if string.sub(request:filepath(),1,12) == "/api/public/" then
--公共开放接口
return true
elseif string.sub(request:filepath(),1,11) == "/api/admin/" then
--管理员目录,需要验证权限
print(param("key"),"\t")
if param("key") == nil or param("key") ~= "123456" then
response:send("key不正确")
return false
end
end
return true
else
response:send("仅允许访问 /api/public 和 /api/admin 目录")
return false
end