Open XHMM opened 3 years ago
The reason is that the "query", "body" and "params" are processed after route middleware. So before action middlewares called, they are merged into req.$params
, so you can modify through it, it will be the ctx.params
.
Thanks for reply, with the help of view source code, I understood the internal.
I think the document description is not clear, which can make people mistakenly think that the use of the two middleware is the same, maybe should point out the difference?
Yeah, maybe the documentation needs some improvements to this topic.
When route-level middleware changed request body or query, action can get changed data, but if alias-level middleware changed it, it not work.
Here is a reproduce demo: after run
npm run dev
, then runcurl -X POST localhost:8080/test
, you can find the (maybe) bug.