siren-mount
v1.0.0
Published
Mount other Koa applications or middleware to a given pathname pattern.
Readme
An mounting middleware for koa
siren-mount is modified from the koa-mount by:
- Support for express path using path-to-regexp.
Installation
npm install --save siren-mountUsage
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

