我有一个简单的koa.js设置与koa-route和koa-ejs.
var koa = require('koa'); var route = require('koa-route'); var add_ejs = require('koa-ejs'); var app = koa(); add_ejs(app,{…}); app.use(function *(next){ console.log( 'to do layout tweak for all requests' ); yield next; }); app.use(route.get('/',function *(name) { console.log( 'root action' ); yield this.render('index',{name: 'Hello' }); }));