koa-easy-route
v1.0.2
Published
configuration-based routing for koa.js
Downloads
3
Maintainers
Readme
Koa Easy Route
Configuration-based routing for Koa.js... the Grunt of routing
Setup
Install (and mark) the dependency-
npm install --save koa-easy-route
Usage
var router = require('koa-easy-route');
app.use(router([
{
method: 'get',
path: '/',
handler: function *(next) {
yield next
this.body = 'text'
yield next
},
middleware: [
function *(next) {
yield next
this.body = 'real text'
}
]
},
{
method: 'post',
path: '/',
handler: function *(next) {
this.body = 'post worked'
}
}
]))
A route must contain a method
, path
, and handler
. You may
optionally also specify middleware[]
, which will be compose'd.