Skip to content

Conversation

@captainsafia
Copy link
Member

@captainsafia captainsafia commented Mar 11, 2022

Closes #40513

@ghost ghost added the area-runtime label Mar 11, 2022
@captainsafia captainsafia added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-runtime labels Mar 11, 2022
@captainsafia captainsafia requested a review from a team March 12, 2022 03:26
@captainsafia captainsafia marked this pull request as ready for review March 12, 2022 03:29
Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a test be added that asserts some endpoint metadata?

/// <returns>An awaitable result of calling the handler and apply
/// any modifications made by filters in the pipeline.</returns>
ValueTask<object?> InvokeAsync(RouteHandlerFilterContext context, Func<RouteHandlerFilterContext, ValueTask<object?>> next);
ValueTask<object?> InvokeAsync(RouteHandlerInvocationContext context, RouteHandlerFilterDelegate next);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we feel about adding a RouteHandlerContext parameter? We can try to approve this over email if we like it.

Suggested change
ValueTask<object?> InvokeAsync(RouteHandlerInvocationContext context, RouteHandlerFilterDelegate next);
ValueTask<object?> InvokeAsync(RouteHandlerContext routeContext, RouteHandlerInvocationContext invocationContext, RouteHandlerFilterDelegate next);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This should e a constructor argument, like middleware has the magic next no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does middleware pass the magic next?

The implementation I just pushed passes the RouteHandlerContext as an argument to the object factory generated when the user utilizes the AddFilter<TFilterType>() overload.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up: #40724

/// provided to a route handler.
/// </summary>
public class RouteHandlerInvocationContext
public sealed class RouteHandlerInvocationContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't seal this one. We'll end up un sealing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this during API review. Unsealing doesn't have a cost, but sealing does so we are taking the more flexible option to start.

If we ship the parameters change in preview4, it shouldn't be too bad.

@captainsafia captainsafia enabled auto-merge (squash) March 16, 2022 00:23
@captainsafia captainsafia merged commit 5fa80eb into dotnet:main Mar 16, 2022
@ghost ghost added this to the 7.0-preview3 milestone Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for filter factory to minimal APIs

4 participants