23 Star 48 Fork 17

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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/oneoo/aLiLua.git
[email protected]:oneoo/aLiLua.git
oneoo
aLiLua
aLiLua
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385