0.0.3 • Published 9 years ago

koa-rroute v0.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

Koa-Regex-Route

Simple Routing For Koa Apps

Instead of a lengthy tutorial, have a look at the following example:

// Assume app to be a koa application instance

var r = require('koa-rrouter');

app.use(r.get(/^\/test\/(\d+)$/, function *(next) {
  this.body = 'Got route test with id ' + this.params[0];
}));

app.use(function *(next) {
  this.body = 'Route test not used';
});

It is also possible to specify a stack of middleware to be executed on a route:

app.use(r.post(/^\/admin\/update$/, [isLoggedIn, update]));