Passing options with UseInterceptor#860
Open
driescroons wants to merge 2 commits intotypestack:developfrom
Open
Passing options with UseInterceptor#860driescroons wants to merge 2 commits intotypestack:developfrom
driescroons wants to merge 2 commits intotypestack:developfrom
Conversation
Member
|
This is a good proposal and I think we could apply this for the middlewares too. For example you have a specific middleware that you want to run before the global ones. |
Author
|
Glad that you bring that up @attilaorosz as I've already been working on that PR as well! A good reason why I think we also need this for middleware is when we want to run authentication before any validation (which is not the case right now), or other middleware, without having to specify it in a specific order on the controller action. I'll add some tests and docs to this PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When using routing controllers, I don't want to explicitly set an interceptor to each controller action even though I (might) want to specify the priority, in how they're applied to the controller action.
For example; I have a:
When I now specify the flush interceptor on global or controller level, it only get's executed after my response has been formatted. I want the flush to happen before any controller action response formatting happens, without having to specify the flush interceptor, on every controller action, below the response formatting interceptor.
This PR suggests a way to pass and specify options (in this case mostly for the priority prop) to the interceptors, and sorts them according to importance before being applied to each controller action.
This PR still requires tests and additional docs, but I want to get some opinions whether this is something that could be merged.
Local development setup used: #861
Project I tested this with (above setup required): https://github.com/driescroons/routing-controllers-interceptor-priority-testing
Checklist
Update index.md)develop)npm run prettier:checkpassesnpm run lint:checkpasses