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:
parent
706a21e4bb
commit
0da98332c5
@ -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" }
|
||||
}
|
||||
})
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user