1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

add api doc

This commit is contained in:
lxsang 2020-06-24 19:49:19 +02:00
parent 706a21e4bb
commit 0da98332c5
2 changed files with 27 additions and 2 deletions

View File

@ -2,10 +2,11 @@ require(CONTROLLER_ROOT..".doccontroller")
DocController:subclass("AntosController", {
path_map = {
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",
elinks = {
{ name = "API", url = "https://doc.iohub.dev/antos/api/" }
{ name = "API", url = "https://doc.iohub.dev/antos/api/index.html" }
}
})

View File

@ -165,6 +165,30 @@ function DocController:search(...)
return true
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(...)
local args = {...}
return self:index(table.unpack(args))