0.0.2 • Published 12 years ago

recursive v0.0.2

Weekly downloads
39
License
-
Repository
github
Last release
12 years ago

思想: 该模块依赖于已有的app.get, app.post方法,仅是简单对其封装 建立一个类似于django urlpattern的可以扩展的route 分配器

以便能够建立可以复用的app

设计方案: 对于主 route 通过主动调用done函数来运行主设定的main函数, 而子route则通过dispatch 进行召唤 主route和子route 写法都如下,子route还可以嵌套下层route,当然在最下层的route是没有调用dispatch的

use manual

##############################################################

routes.js

var routes = require('recursive').Routes;

routes.main = function(){

this.get('', func); this.get('News/', func); this.get('T/', func);

this.post('News/', func); this.post('T/', func);

this.dispatch('register/', require('./apps/register/routes'); this.dispatch('friends/', require('./apps/friends/routes');

} module.exports = routes;

下面是app.js中的调用方法 ##############################################################

app.js

... var routes = require('./routes'); ... routes.done(app); ...

##############################################################