#koa-derouter
Koa derouter, but a router of koa.
- Support REST API.
- Fixed special url can not get query params.
- Fixed static resouce download in IE/Edge.
- Add params suport.
- First commit.
- In app.js
var koa = require('koa'),
koa_gzip = require('koa-gzip'),
koa_derouter = require('koa-derouter');
var app = koa();
var derouter = koa_derouter({
exception:{
"/home/index":/^\/$/,
},
default_controller:"index",
default_action : "index",
controller_path : process.cwd() + "/controller",
resource_reg : /^\/(asset\/|upload\/|favicon\.ico|robot\.txt)/,
resource_path : process.cwd()
});
app.use(koa_gzip());
app.use(derouter);
app.listen(3000);
- In a controller
module.exports = {
index : function*(id){
var a = id;
this.body = a;
},
art : {
GET : function *(id){
this.body = id;
},
POST : function *(aid){
this.body = toString.call(aid);
}
}
}