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

60 lines
1.6 KiB
Lua
Raw Normal View History

2018-08-22 19:38:36 +02:00
2018-08-22 20:02:45 +02:00
-- the rewrite rule for the framework
-- should be something like this
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
2018-08-22 19:38:36 +02:00
-- some global variables
DIR_SEP = "/"
2018-10-17 19:48:31 +02:00
WWW_ROOT = __ROOT__.."/apps"
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
HTTP_ROOT = "https://apps.lxsang.me"
end
-- class path: path.to.class
BASE_FRW = ""
-- class path: path.to.class
CONTROLLER_ROOT = BASE_FRW.."apps.controllers"
MODEL_ROOT = BASE_FRW.."apps.models"
-- file path: path/to/file
2018-08-22 19:38:36 +02:00
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
2018-08-22 19:38:36 +02:00
-- require needed library
require(BASE_FRW.."silk.api")
POLICY.mimes["application/wasm"] = true
2018-08-22 19:38:36 +02:00
-- registry object store global variables
local REGISTRY = {}
-- set logging level
2018-10-09 12:14:33 +02:00
REGISTRY.logger = Logger:new{ levels = {INFO = false, ERROR = true, DEBUG = false}}
2018-08-22 19:38:36 +02:00
REGISTRY.db = DBHelper:new{db="iosapps"}
REGISTRY.layout = 'default'
2018-09-17 19:43:24 +02:00
REGISTRY.fileaccess = true
2018-08-22 19:38:36 +02:00
REGISTRY.db:open()
local router = Router:new{registry = REGISTRY}
REGISTRY.router = router
router:setPath(CONTROLLER_ROOT)
--router:route('edit', 'post/edit', "ALL" )
-- example of depedencies to the current main route
2018-10-09 12:14:33 +02:00
--[[ -- each layout may have different dependencies
local default_routes_dependencies = {
edit = {
url = "post/edit",
visibility = {
shown = true,
routes = {
["post/index"] = true
}
}
},
--category = {
-- url = "cat/index",
-- visibility = "ALL"
--}
2018-10-09 12:14:33 +02:00
}
router:route('default', default_routes_dependencies )]]
2018-08-22 19:38:36 +02:00
router:delegate()
if REGISTRY.db then REGISTRY.db:close() end