koa-rroute

0.0.3 • Public • Published

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]));

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i koa-rroute

    Weekly Downloads

    1

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • graczykr