1
当我使用金字塔框架时,我发现了很好的方法来路由URL,命名为遍历。在电梯框架中的URL遍历
金字塔遍历首先映射遍历序列的请求路径(例如'/ a/b/c'=> [u'a',u'b',u'c']),然后遍历它通过资源图。
我正在寻找一些图书馆或Appoach在Lift中进行URL遍历。
当我使用金字塔框架时,我发现了很好的方法来路由URL,命名为遍历。在电梯框架中的URL遍历
金字塔遍历首先映射遍历序列的请求路径(例如'/ a/b/c'=> [u'a',u'b',u'c']),然后遍历它通过资源图。
我正在寻找一些图书馆或Appoach在Lift中进行URL遍历。
如果没有这样的库,基础知识不会很难实现。
伪代码:
//handlers is a hashtable which maps resource class -> handler function
my_catchall_route_handler(url)
{
context = My_root_resource()
for segment in split(url)
try
context = context.get_child(segment) //try to get child resource
except
break //found ultimate context
handler = handlers(context)
handler();
}
这是什么和电梯的地图之间的区别?例如'Menu.i(“我的C页”)/“a”/“b”/“c”' –
你能更好地解释金字塔是什么吗? – nafg