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
ctx.params
I have a middleware(let's call it mw) which will use ctx.params to get the parameter in a path.
mw
If I write:
router.use(mw)
The ctx.params in the mw is {}
{}
But if I write:
router.use([ '/example/:id', '/example2/:id', ], mw)
The ctx.params in the mw is { id: 'some_id' }
{ id: 'some_id' }
I want my middleware to be called for every route and I want to get the right ctx.params.
Is there any way to solve this problem?
The text was updated successfully, but these errors were encountered:
after init router router.stack.forEach(routerItem => routerItem.stack.unshift(mw))
router.stack.forEach(routerItem => routerItem.stack.unshift(mw))
Sorry, something went wrong.
Work around koa-router bug
14267c6
ZijianHe/koa-router#347
Does a cleaner way to do this exist?
@zhuscat
const router = new Router({ prefix: "/users/:id", }) // GET /users/123 router.use("*", async (ctx, next) => { // ctx.params = {id: "123"} await next() })
No branches or pull requests
I have a middleware(let's call it
mw
) which will use ctx.params to get the parameter in a path.If I write:
The
ctx.params
in themw
is{}
But if I write:
The
ctx.params
in themw
is{ id: 'some_id' }
I want my middleware to be called for every route and I want to get the right
ctx.params
.Is there any way to solve this problem?
The text was updated successfully, but these errors were encountered: