recursive

0.0.2 • Public • Published

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

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

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

use manual 注意: 写路径的时候最前面的‘/’不用写 ,分配子route的时候如果分配的prefix没有以‘/’结尾,会自动在prefix上添加‘/’

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

routes.js

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

routes.main = function(){

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

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

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

} module.exports = routes;

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

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i recursive

Weekly Downloads

141

Version

0.0.2

License

none

Last publish

Collaborators

  • ruandao