-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Make route handler filters work for MVC controllers #42557
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
Conversation
242a80c
to
84cffde
Compare
fb67fc4
to
7fde485
Compare
src/Mvc/Mvc.RazorPages/test/Infrastructure/PageActionEndpointDataSourceTest.cs
Outdated
Show resolved
Hide resolved
676f5ac
to
27f98b7
Compare
src/Mvc/Mvc.RazorPages/test/Infrastructure/PageActionEndpointDataSourceTest.cs
Outdated
Show resolved
Hide resolved
- This change makes route handler filters work better with MVC controller actions by wrapping the action delegate directly. - To do so we need to expose the RouteHandlerFilters on the RouteEndpointBuilder and use them in MVC - Implement GetEndpointGroup on ActionEndpointDataSource - Reuse the action method executor logic to pick the best invoker even in the filter scenario. - Added tests
27f98b7
to
60ab760
Compare
- Make sure conventions are applied in the right order. - Added tests
- If the initial delegate is the same as the final delegate then skip the filter pipeline.
OK this is ready for another pass. |
IReadOnlyList<Action<EndpointBuilder>> conventions, | ||
IReadOnlyList<Action<EndpointBuilder>> perRouteConventions) | ||
{ | ||
// REVIEW: The RouteEndpointDataSource adds HttpMethodMetadata before running group conventions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's goodness to give access to this metadata to group conventions. I don't anticipate that it'll be as required here as it is in REDS, where it's needed for OpenAPI support. IMO, nice to have but not groundbreaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's goodness to give access to this metadata to group conventions. I don't anticipate that it'll be as required here as it is in REDS, where it's needed for OpenAPI support. IMO, nice to have but not groundbreaking.
Open API fixes it with Finally 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely fix this inconsistency. RouteEndpointDataSource has the nicer, more convenient behavior. Maybe we can sneak this into #43225.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halter73 Sure -- I can adjust. Do any other conventions rely on this particular metadata? OpenAPI was the only one that came to mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we’d need a scenario where it matters. This code needs to be re-worked to do that I think. We don’t want group conventions to override endpoint metadata in attributes and metadata set from the action descriptor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code needs to be re-worked to do that I think. We don’t want group conventions to override endpoint metadata in attributes and metadata set from the action descriptor
I agree with this part.
I think we’d need a scenario where it matters.
I think consistency is enough of a reason to say we ought to do this. I can agree that fixing this isn't the highest priority thing, and if it's too complicated it might not be worth doing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yes, WithOpenApi is the only thing I know of that already depends on this and it is fixed by Finally
.
@@ -4,7 +4,9 @@ | |||
using System.Net; | |||
using System.Net.Http; | |||
using System.Net.Http.Json; | |||
using System.Text.Json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needed?
using System.Text.Json; |
Fixes #42799
Fixes #42593