mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-04-20 02:26:45 +02:00
add api doc
This commit is contained in:
parent
706a21e4bb
commit
0da98332c5
@ -2,10 +2,11 @@ require(CONTROLLER_ROOT..".doccontroller")
|
|||||||
DocController:subclass("AntosController", {
|
DocController:subclass("AntosController", {
|
||||||
path_map = {
|
path_map = {
|
||||||
vfs_path = "home://doc/antos",
|
vfs_path = "home://doc/antos",
|
||||||
local_path = "/home/mrsang/doc/antos"
|
local_path = "/home/mrsang/doc/antos",
|
||||||
|
api_path = "/opt/www/htdocs/doc/antos"
|
||||||
},
|
},
|
||||||
name = "antos",
|
name = "antos",
|
||||||
elinks = {
|
elinks = {
|
||||||
{ name = "API", url = "https://doc.iohub.dev/antos/api/" }
|
{ name = "API", url = "https://doc.iohub.dev/antos/api/index.html" }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -165,6 +165,30 @@ function DocController:search(...)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function DocController:api(...)
|
||||||
|
local args = {...}
|
||||||
|
if not self.path_map.api_path then
|
||||||
|
return self:actionnotfound(table.unpack(args))
|
||||||
|
end
|
||||||
|
local rpath = "index.html"
|
||||||
|
if #args ~= 0 then
|
||||||
|
rpath = implode(args,"/")
|
||||||
|
end
|
||||||
|
local path = self.path_map.api_path.."/"..rpath
|
||||||
|
|
||||||
|
if ulib.exists(path) then
|
||||||
|
local mime = std.mimeOf(path)
|
||||||
|
if POLICY.mimes[mime] then
|
||||||
|
std.sendFile(path)
|
||||||
|
else
|
||||||
|
self:error("Access forbidden: "..path)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:error("File not found or access forbidden: "..path)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function DocController:actionnotfound(...)
|
function DocController:actionnotfound(...)
|
||||||
local args = {...}
|
local args = {...}
|
||||||
return self:index(table.unpack(args))
|
return self:index(table.unpack(args))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user