Skip to content

Commit

Permalink
Merge pull request #4 from teawithfruit/patch-1
Browse files Browse the repository at this point in the history
Added an example for koa-router.
  • Loading branch information
kudos committed Nov 28, 2015
2 parents dda3138 + ea835a4 commit 71450b0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/koa-router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var koa = require('koa');
var websockify = require('koa-websocket');
var router = require('koa-router');
var app = koa();

var api = router();
var socket = websockify(app);

api.get('/*', function* (next) {
this.websocket.send('Hello World');
this.websocket.on('message', function(message) {
console.log(message);
});
});

app.ws.use(api.routes()).use(api.allowedMethods());
app.listen(3000);

0 comments on commit 71450b0

Please sign in to comment.