README
koa
An mounting middleware forsiren-mount is modified from the koa-mount by:
- Support for express path using path-to-regexp.
Installation
npm install --save siren-mount
Usage
The usage is the same as koa-mount, except:
Regular Expression Path
You can use regular expression as prefix:
var app = koa();
var router = koa();
app.use(mount(/\/([^\/]+)\/?/i, function *() {
// Matches /abc, /abc/, /abcdadc/dsd
}));
Parameter Access
You can use ctx.params
to access the URL parameters:
var app = koa();
var router = koa();
app.use('/:id', function *() {
console.log(this.params.id);
}));
License
MIT