1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-28 02:08:22 +01:00
antd-web-apps/get/router.lua
DanyLE a76942f2f3
All checks were successful
gitea-sync/antd-web-apps/pipeline/head This commit looks good
WIP: make code compatible with new SILK API
2023-04-26 18:51:03 +02:00

54 lines
1.3 KiB
Lua

-- the rewrite rule for the framework
-- should be something like this
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
-- some global variables
package.path = _SERVER["LIB_DIR"].."/lua/?.lua"
require("silk.api")
WWW_ROOT = __ROOT__.."/get"
if HEADER.Host then
HTTP_ROOT= "https://"..HEADER.Host
else
HTTP_ROOT = "https://get.iohub.dev"
end
-- class path: path.to.class
CONTROLLER_ROOT = "get.controllers"
MODEL_ROOT = "get.models"
-- file path: path/to/file
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
function NotfoundController:index(...)
local args = {...}
local name = args[1] or nil
if not name then
return self:error("Unknown script")
end
name = name:gsub("Controller",""):lower()
local path = WWW_ROOT..DIR_SEP.."shs"..DIR_SEP..name..".sh"
if ulib.exists(path) then
std.sendFile(path)
else
self:error("No script found: "..path)
end
return false
end
-- registry object store global variables
local REGISTRY = {}
-- set logging level
REGISTRY.logger = Logger:new{ level = Logger.INFO}
REGISTRY.layout = 'default'
REGISTRY.fileaccess = false
local router = Router:new{registry = REGISTRY}
REGISTRY.router = router
router:setPath(CONTROLLER_ROOT)
--router:route('edit', 'post/edit', "ALL" )
router:route('default', default_routes_dependencies )
router:delegate()