koa-rroute
v0.0.3
Published
Simple Koa route middleware based on raw regexp
Downloads
3
Readme
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]));