The problem is that when I use router.use(someMiddleware), in that middleware I have access to payload from query string via ctx.query and to payload from request body via ctx.request.body but I haven't access to route params and this is not so convenient especially in my case.
To be more clear I will tell my story. I have a validation middleware which works like this.
It takes request method from ctx.request.method and matched route from ctx._matchedRoute and using that it takes necessary validation rules from validation schemas that look like this:
and for each type of payload, if it exists in the scheme, it checks for validity and problem comes here when it tries to validate params because params are not available in the middleware defined using router.use method.
This pull request fixes this type of problems and I think this will will bring much good in the future.
The problem is that when I use
router.use(someMiddleware)
, in that middleware I have access to payload from query string viactx.query
and to payload from request body viactx.request.body
but I haven't access to route params and this is not so convenient especially in my case.To be more clear I will tell my story. I have a validation middleware which works like this. It takes request method from
ctx.request.method
and matched route fromctx._matchedRoute
and using that it takes necessary validation rules from validation schemas that look like this:and for each type of payload, if it exists in the scheme, it checks for validity and problem comes here when it tries to validate params because params are not available in the middleware defined using
router.use
method.This pull request fixes this type of problems and I think this will will bring much good in the future.
Thanks!