-
-
Notifications
You must be signed in to change notification settings - Fork 1
Grouping
Ieuan Walker edited this page Dec 30, 2025
·
4 revisions
Endpoint grouping allows you to organise related endpoints under common route prefixes and apply shared configuration. This is particularly useful for versioning, common middleware, or organising endpoints by feature area.
Create a class that implements IEndpointGroup:
using IeuanWalker.MinimalApi.Endpoints;
public class TodoEndpointGroup : IEndpointGroup
{
public static RouteGroupBuilder Configure(WebApplication app)
{
return app
.MapGroup("api/v{version:apiVersion}/todos")
.WithTags("Todos")
.RequireAuthorization(); // Apply authorization to all endpoints in this group
}
}Reference the group in your endpoints using the Group<T>() extension method:
public class GetAllTodosEndpoint : IEndpointWithoutRequest<ResponseModel[]>
{
public static void Configure(RouteHandlerBuilder builder)
{
builder
.Group<TodoEndpointGroup>() // Reference the endpoint group
.Get() // Relative path within the group
.WithSummary("Get all todos")
.WithDescription("Retrieves all todos from the store")
.Version(1.0);
}
public async Task<ResponseModel[]> Handle(CancellationToken ct)
{
// Implementation
return await GetTodosAsync();
}
}This is the equivalent of the minimal api
MapGroupextension method - https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/route-handlers?view=aspnetcore-9.0#route-groups
Getting Started
Endpoints
- Endpoint interfaces
- HTTP verbs
- Request binding
- Grouping
- Returning multiple different responses
- Dependency injection
Validation
- Setup
- Data annotations
- Fluent validation
- Disabling validation
- Manually return BadRequest with validation errors
Output Caching
OpenAPI & Documentation