1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-28 18:28:21 +01:00
antd-web-apps/get/router.lua

54 lines
1.3 KiB
Lua
Raw Normal View History

2018-10-03 11:28:39 +02:00
-- 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")
2018-10-17 19:48:31 +02:00
WWW_ROOT = __ROOT__.."/get"
2018-10-19 11:20:56 +02:00
if HEADER.Host then
HTTP_ROOT= "https://"..HEADER.Host
2018-10-17 19:48:31 +02:00
else
2020-06-25 21:55:55 +02:00
HTTP_ROOT = "https://get.iohub.dev"
2018-10-17 19:48:31 +02:00
end
2018-10-03 11:28:39 +02:00
-- class path: path.to.class
CONTROLLER_ROOT = "get.controllers"
MODEL_ROOT = "get.models"
2018-10-03 11:28:39 +02:00
-- 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
2022-02-23 09:21:06 +01:00
std.sendFile(path)
2018-10-03 11:28:39 +02:00
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}
2018-10-03 11:28:39 +02:00
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()