liveBook · Manning

Route group

As explained in ASP.NET Core in Action, 3e

A route group is a minimal API organization construct that applies a common route prefix and shared endpoint configuration to multiple endpoints.

A route group organizes related minimal API endpoints under one route prefix and shared endpoint configuration. It removes repeated path segments and repeated filter registration, keeping endpoint definitions easier to read. section 5.5

Group fruit endpoints

Create a group with `RouteGroupBuilder fruitApi = app.MapGroup("/fruit")`. Map endpoints on `fruitApi` instead of `app`; their routes inherit `/fruit`. Create a nested group with `fruitApi.MapGroup("/").AddEndpointFilter(ValidationHelper.ValidateIdFactory)` so related endpoints share ID validation. section 5.5

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains MapGroup, inherited prefixes, nested groups, and shared filters, but does not descend into framework internals.
Examples
Uses a fruit API with grouped GET, POST, PUT, and DELETE endpoints plus shared ID validation.
What it assumes
Assumes basic minimal API endpoint mapping and endpoint filters, while demonstrating grouping from a WebApplication instance.
What you can do after
Apply it via MapGroup to define consistent minimal API routes and shared endpoint filters with less duplication.
How it connects
Connects minimal APIs, routing, endpoint filters, and RouteGroupBuilder.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.