我想在 node.js 中编写重要的动态干净 URL。例如
mynodeserver.com/browse/itemid
代替
mynodeserver.com/browse?id=itemid
现在我的静态干净 url(浏览、登录、注册等)是基于字符串比较的,这显然不是这个问题的完整解决方案。
var pathname = url.parse(request.url).pathname;
//check if there is a request handler for this path
if (typeof handle[ pathname ] === 'function')
{
handle[pathname]( response, request, postData );
}
是否有本地方式(或轻量级插件)来编写非平凡的干净 URL?
我正在使用 Cloud9 IDE