1 Star 0 Fork 17

zruibin / aLiLua

forked from oneoo / aLiLua 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
route.lua 669 Bytes
一键复制 编辑 原始数据 按行查看 历史
oneoo 提交于 2014-04-14 14:27 . fix router example
routes = {}
routes['^/(.*).(jpg|gif|png|css|js|ico|swf|flv|mp3|mp4|woff|eot|ttf|otf|svg)'] = function()
header('Cache-Control: max-age=864000')
sendfile(headers.uri)
end
routes['^/user/:user_id'] = function(r)
print('User ID: ', r.user_id)
end
routes['^/user/:user_id/:post(.+)'] = function(r)
print('User ID: ', r.user_id)
print(' Post: ', r.post)
end
routes['^/(.*)'] = function(r)
dofile('/index.lua')
end
--[[
others you want :)
]]
-- if the 3rd argument is a path, then router will try to get local lua script file first
if not router(headers.uri, routes, '/') then
header('HTTP/1.1 404 Not Found')
echo('File Not Found!')
end
1
https://gitee.com/zruibin/aLiLua.git
git@gitee.com:zruibin/aLiLua.git
zruibin
aLiLua
aLiLua
master

搜索帮助