-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[API] RequestDelegateFactory.Create RequestDelegate overload #46024
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
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
This seems to niche for a public API, whats the scenario for this being a public API? |
The caller is in another project (Microsoft.AspNetCore.Routing) so internal won’t work. |
It's just the filters that need to be applied, right? It's tempting to just apply the filters manually without RDF. Edit: I've looked at the PR now. I see the appeal. We also want to start handling serializing the response of |
No longer required. |
Background and Motivation
Today
RequestDelegateFactory
hasCreate
methods that takeDelegate
. However, there are situations where we also want to wrap aRequestDelegate
in a new request delegate. For example, the endpoint has request filters.RequestDelegateFactory.Create(Delegate, ...)
is currently used for both types of delegates. However, it is beneficial to have separate overloads forRequestDelegateFactory.Create(Delegate, ...)
andRequestDelegateFactory.Create(RequestDelegate, ...)
.The
RequestDelegate
overload doesn't need to useSystem.Linq.Expressions
to build a request filter pipeline. Apps that only map request delegate endpoints can be statically analyzed not to use expressions and the expressions assembly can be trimmed on publish.Proposed API
namespace Microsoft.AspNetCore.Http; public static class RequestDelegateFactory { + public static RequestDelegateResult Create(RequestDelegate handler, RequestDelegateFactoryOptions? options); }
We don't need
InferMetadata
method orRequestDelegateMetadataResult
overloads because request delegates don't have parameters or return values to gather metadata from.Usage Examples
Alternative Designs
The alternative is to build the filter pipeline for a
RequestDelegate
outside of the delegate factory in theMicrosoft.AspNetCore.Routing
project. However, because it is a separate project fromRequestDelegateFactory
, there is some duplication between routing and HTTP extensions projects.See #46020 for an example of messiness.
Risks
The text was updated successfully, but these errors were encountered: