We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I have this sample code:
const parentRouter = new Router(); const nestedRouter = new Router(); nestedRouter .get('/first-nested-route', function *(next) { console.log('first nested middleware'); yield next; }) .get('/second-nested-route', function *(next) { console.log('second nested middleware'); yield next; }) .get('/third-nested-route', function *(next) { console.log('third nested middleware'); yield next; }); parentRouter.use('/parent-route', function *(next) { console.log('parent middleware'); yield next; }, nestedRouter.routes() ); app.use(parentRouter.routes());
I requested a /parent-route/first-nested-route and got this debug output:
/parent-route/first-nested-route
koa-router GET /parent-route/first-nested-route +5s koa-router test /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +2ms koa-router test /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +1ms koa-router test /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +0ms koa-router test /parent-route/first-nested-route /^\/parent-route\/first-nested-route(?:\/(?=$))?$/i +0ms koa-router test /parent-route/second-nested-route /^\/parent-route\/second-nested-route(?:\/(?=$))?$/i +0ms koa-router test /parent-route/third-nested-route /^\/parent-route\/third-nested-route(?:\/(?=$))?$/i +1ms koa-router dispatch /parent-route/first-nested-route /^\/parent-route\/first-nested-route(?:\/(?=$))?$/i +0ms koa-router dispatch /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +1ms koa-router dispatch /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +0ms koa-router dispatch /parent-route /^\/parent-route(?:\/(?=$))?(?=\/|$)/i +0ms
And additional output:
parent middleware parent middleware parent middleware first nested middleware
I use the koa-router@5.2.2. Why is parent middleware called several times? Isn't that a bug? Thank you for any inquiries.
koa-router@5.2.2
The text was updated successfully, but these errors were encountered:
2108cbe
Do not register middleware more than once.
f54d9b0
- Fixes ZijianHe#184.
No branches or pull requests
Hi, I have this sample code:
I requested a
/parent-route/first-nested-route
and got this debug output:And additional output:
I use the
koa-router@5.2.2
. Why is parent middleware called several times? Isn't that a bug? Thank you for any inquiries.The text was updated successfully, but these errors were encountered: