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

[release/7.0-preview4] Add MapGroup #41367

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 25, 2022

Backport of #41265 to release/7.0-preview4

/cc @halter73

Add MapGroup

Add a new MapGroup() extension method to IEndpointRouteBuilder.

Description

This returns a new builder for defining groups of endpoints with a common prefix that implements both the IEndpointRouteBuilder and IEndpointConventionBuilder interfaces. This can be used to add endpoints with the given group prefix, and to customize those endpoints using conventions.

Sample Usage

var app = WebApplication.Create(args);

var group = app.MapGroup("/todos");
group.MapGet("/", (int id, TodoDb db) => db.ToListAsync());
group.MapGet("/{id}", (int id, TodoDb db) => db.GetAsync(id));
group.MapPost("/", (Todo todo, TodoDb db) => db.AddAsync(todo));

var nestedGroup = group.MapGroup("/{org}");
nestedGroup.MapGet("/", (string org, TodoDb db) => db.Filter(todo => todo.Org == org).ToListAsync());
nestedGroup.RequireCors("AllowAll");

// This applies to all endpoints defined on group and nestedGroup
group.RequireAuthorization();

// ...

Fixes #36007

Customer Impact

This is a new highly requested feature that makes organizing groups of endpoints easier and less repetitve.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

This is a new API. The change to existing code is very small and non-impactful unless the new MapGroup method is called.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@halter73 halter73 added Servicing-consider Shiproom approval is required for the issue area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Apr 25, 2022
@ghost
Copy link

ghost commented Apr 25, 2022

Hi @github-actions[bot]. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@halter73 halter73 added this to the 7.0-preview4 milestone Apr 25, 2022
@Pilchie Pilchie added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Apr 26, 2022
@Pilchie
Copy link
Member

Pilchie commented Apr 26, 2022

This was approved over email.

@sebastienros sebastienros merged commit bd6dbc1 into release/7.0-preview4 Apr 26, 2022
@sebastienros sebastienros deleted the backport/pr-41265-to-release/7.0-preview4 branch April 26, 2022 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants