-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
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
question: Routes with path parameters continue middleware chain (but those without, don't)? #1356
Comments
Hi, I just tested this and in my case both requests trigger someMiddlewareFuction. Which express and routing-controllers versions are you using? |
Ahh the plot thickens! package.json contents
package-lock.json contents
|
Well, this is a bit frustrating. I'm able to reproduce your issue. The problem is that express actually executes both controllers if you call |
Hmm so if I'm understanding correctly If so, does that mean if I add a controller function like the following (at the bottom), it would effectively treat the testA/testB endpoints consistently?
|
It would treat them consistently but also incorrectly. The short circuit was probably never meant to work this way and it was assumed the middlewares would be registered in |
Hello! I have just encountered this myself with a global routing controllers middleware - I have a generic UPDATE: I am now using an interceptor to do what I want currently 🫡 |
I was trying to:
I'm currently adding routing-controllers to an existing application and am in the progress of a progressive migration of endpoints.
The problem:
Recently I've noticed that one of my middleware functions that is attached to the express server (outside of a routing-controllers Controller) appears to be invoked after some of the endpoints (defined within a Controller) are hit but not others.
The endpoints that continue down the middleware chain contain path parameters and the endpoints that don't appear to be terminal.
Any ideas why this behaviour might occur? It seems strange that the behaviour isn't consistent for all endpoints reached.
Example to replicate:
Using the below code example and sending a request to
/test/fixed
results in the following being logged:However sending a request to
/test/path
results in the following being logged:Ideally either both requests trigger the
someMiddlewareFunction
middleware function or both of them don't; but at the moment I'm just curious to know why there might be a difference between the two?The text was updated successfully, but these errors were encountered: