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 new "MapAction" overloads #30448

Closed
halter73 opened this issue Feb 25, 2021 · 1 comment · Fixed by #30556
Closed

Add new "MapAction" overloads #30448

halter73 opened this issue Feb 25, 2021 · 1 comment · Fixed by #30556
Assignees
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-minimal-actions Controller-like actions for endpoint routing
Milestone

Comments

@halter73
Copy link
Member

halter73 commented Feb 25, 2021

  1. Don't call the overloads "MapAction". Add overloads to the existing MapGet/MapPost/MapDelete/Map extension methods. We should remove the existing MapAction method.
namespace Microsoft.AspNetCore.Builder
{
    public static class EndpointRouteBuilderExtensions
    {
        public static IEndpointConventionBuilder Map(this IEndpointRouteBuilder endpoints, string pattern, Delegate action);
        public static IEndpointConventionBuilder MapGet(this IEndpointRouteBuilder endpoints, string pattern, Delegate action);
        public static IEndpointConventionBuilder MapPost(this IEndpointRouteBuilder endpoints, string pattern, Delegate action);
        public static IEndpointConventionBuilder MapPut(this IEndpointRouteBuilder endpoints, string pattern, Delegate action);
        public static IEndpointConventionBuilder MapDelete(this IEndpointRouteBuilder endpoints, string pattern, Delegate action);
}
  1. Create overloads without the string pattern parameter for people you still want to use RouteAttribute. This should throw an InvalidOperationException if there's no route attribute.
namespace Microsoft.AspNetCore.Builder
{
    public static class EndpointRouteBuilderExtensions
    {
        public static IEndpointConventionBuilder Map(this IEndpointRouteBuilder endpoints, Delegate action);
    }
}
@halter73 halter73 added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-minimal-actions Controller-like actions for endpoint routing labels Feb 25, 2021
@halter73
Copy link
Member Author

Sadly, this will probably cause some code that works today to break at the source level. The compiler would be unable to infer the parameter type is HttpContext in the following:

app.MapGet("/", ctx => ctx.Respsone.WriteAsync("Hello, World!"));

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Feb 25, 2021
@mkArtakMSFT mkArtakMSFT added this to the 6.0-preview3 milestone Feb 25, 2021
@ghost ghost closed this as completed in #30556 Mar 2, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 1, 2021
@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-minimal-actions Controller-like actions for endpoint routing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants