Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Created March 13, 2014 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjohnson/9521716 to your computer and use it in GitHub Desktop.
Save gjohnson/9521716 to your computer and use it in GitHub Desktop.
Tacking shit onto koa context
var koa = require('koa');
var uuid = require('node-uuid');
var app = koa();
app.use(function *(next) {
yield next;
this.log('yippie');
this.body = 'yoyoyo';
});
app.use(function *() {
this.id = uuid.v4();
this.log = function(msg) {
console.log('id=%s, message=%s', this.id, msg);
};
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment