Created
June 6, 2015 11:48
-
-
Save danhper/ebb5adbd366daec7eecf to your computer and use it in GitHub Desktop.
Bug with koa-router nested routes with prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const koa = require('koa'); | |
const Router = require('koa-router'); | |
let app = koa(); | |
let router = new Router({ | |
prefix: '/prefix' | |
}); | |
let fooRouter = new Router(); | |
fooRouter.get('/', function *() { | |
this.body = 'nested'; | |
}); | |
router.get('/', function *() { | |
this.body = 'root'; | |
}); | |
router.all('/nested', fooRouter.routes()); | |
app.use(router.routes()); | |
app.listen(8888); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment