Skip to content
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

Add MapPatch overloads to routing #36198

Closed
davidfowl opened this issue Sep 6, 2021 · 2 comments · Fixed by #36818
Closed

Add MapPatch overloads to routing #36198

davidfowl opened this issue Sep 6, 2021 · 2 comments · Fixed by #36818
Labels
api-approved API was approved in API review, it can be implemented area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-web-frameworks feature-minimal-actions Controller-like actions for endpoint routing feature-routing good first issue Good for newcomers.

Comments

@davidfowl
Copy link
Member

davidfowl commented Sep 6, 2021

Background and Motivation

Today we have shortcuts for the most common HTTP methods for route handling (GET, POST, PUT, DELETE) but we don't have PATCH (or OPTIONS, TRACE, HEAD). We should add MapPatch to the set of methods we support. MapPatch is also interesting because people can now write custom binders in minimal APIs to handle the body. Today calling MapMethods(..) is the workaround (https://github.com/felipeoriani/MinimalBlogApi/blob/83732f1785a4c01a63ccf6909ca2a8190c63b4c9/Program.cs#L118) but it's kinda gross.

Proposed API

namespace Microsoft.AspNetCore.Builder
{
    public static class DelegateEndpointRouteBuilderExtensions
    {
+       public static DelegateEndpointConventionBuilder MapPatch(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler);
    }
}

Usage Examples

app.MapPatch("/patch", (Patch<Model> patch)
{
      return patch.Changes;
});

Risks

Low.

Questions:

  • Do we also add RequestDelegate overloads here?
@davidfowl davidfowl added api-suggestion Early API idea and discussion, it is NOT ready for implementation api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Sep 6, 2021
@davidfowl davidfowl added this to Ready in Minimal APIs 6.0 via automation Sep 6, 2021
@davidfowl davidfowl added feature-minimal-actions Controller-like actions for endpoint routing feature-routing labels Sep 6, 2021
@davidfowl davidfowl changed the title Add MapPatch and MapHead overloads to routing Add MapPatch overloads to routing Sep 6, 2021
@rafikiassumani-msft rafikiassumani-msft moved this from Ready to Need review in Minimal APIs 6.0 Sep 7, 2021
@rafikiassumani-msft rafikiassumani-msft added this to the .NET 7 Planning milestone Sep 9, 2021
@rafikiassumani-msft rafikiassumani-msft removed this from Need review in Minimal APIs 6.0 Sep 9, 2021
@pranavkm
Copy link
Contributor

pranavkm commented Sep 20, 2021

API approved. We discussed adding MapHead along with this, but it typically appears in a place where GET and HEAD need to be supported together. MapMethods is what we would recommend in that case. We should also add the RequestDelegate overload as part of this change:

namespace Microsoft.AspNetCore.Builder
{
    public static class DelegateEndpointRouteBuilderExtensions
    {
+       public static DelegateEndpointConventionBuilder MapPatch(this IEndpointRouteBuilder endpoints, string pattern, Delegate handler);
    }
}

namespace Microsoft.AspNetCore.Builder
{
    public static class EndpointRouteBuilderExtensions
    {
+        public static IEndpointConventionBuilder MapPatch(this IEndpointRouteBuilder endpoints, string pattern, RequestDelegate requestDelegate)
    }
}

@pranavkm pranavkm added api-approved API was approved in API review, it can be implemented good first issue Good for newcomers. and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Sep 20, 2021
@noamyogev84
Copy link
Contributor

noamyogev84 commented Sep 21, 2021

hey @pranavkm , i'll be happy to tackle this one 🎉

@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 3, 2021
@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-web-frameworks feature-minimal-actions Controller-like actions for endpoint routing feature-routing good first issue Good for newcomers.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants