Repository navigation
AspNetCore Routes and Groups
A route connects an HTTP method and path to a handler. A group supplies a shared path prefix and registrations to all routes inside it. Partie generates endpoint registration from these declarations.
Handler names determine their generated route attributes:
[BrigadeGroup("/api/v1")]
[AspNetSystemBundle]
[PartieSystemBundle]
public static partial class ApiRoutes
{
[CourseSearchHandlerRoute.Get("/courses/{courseId}")]
public static partial void Search();
[CourseCreateHandlerRoute.Post("/courses")]
public static partial void Create();
}These declarations register GET /api/v1/courses/{courseId} and POST /api/v1/courses. Query handlers generate .Get. Command handlers generate .Post, .Put, .Patch, .Delete, .Head, .Options, .Trace, and .Connect.
The group and every containing type must be non-generic and partial, and cannot be declared with file. A declaration-only route method takes the form static partial void Name();.
After building the ASP.NET Core application, register the generated routes:
var app = builder.Build();
...
app.UsePartieRoutes();Group courses under a shared path and give them shared behavior:
[BrigadeGroup("/api/v1")]
[AspNetSystemBundle]
[PartieSystemBundle]
public static partial class ApiRoutes
{
[BrigadeGroup("/courses")]
[AcademicYearProvider("2026-2027")]
private static partial class Courses
{
[LogCourseSearchPartie]
[CourseSearchHandlerRoute.Get("/{courseId}")]
public static partial void Search();
[CourseCreateHandlerRoute.Post]
public static partial void Create();
}
}The POST attribute has no path, so it uses /api/v1/courses. HTTP routing joins path segments and trims slashes. Groups and routes can use an empty path.
Paths, Providers, Parties, and policies flow from outer groups to inner groups, then to the route. Registrations on the route follow source order. A registration participates only when its operation, request, result, and constraints match. Here, the query-only year Provider does not apply to Create.
Give the route method a RouteHandlerBuilder parameter and a body when you want to configure endpoint metadata:
[CourseSearchHandlerRoute.Get("/{courseId}")]
public static void Search(RouteHandlerBuilder route)
{
route.WithTags("Courses");
route.WithSummary("Find a course by ID");
}RouteHandlerBuilder is in Microsoft.AspNetCore.Builder. This method runs while endpoints are registered. It configures the endpoint; it is not called for each HTTP request. Route method bodies run after inherited and route-level policies.
Overloaded route methods are supported and receive distinct generated names. Give operations clear names so declarations remain easy to find.
Put a Provider or Partie on a group when matching routes in that group need it. Put it on an individual route for a narrower scope. Use Bundles to package a set of registrations and Route policies to share endpoint configuration.
- Home
- Getting started
-
Package guides
- Partie
- Expo
-
Mise
- Database setup
- Table mappings
- Aliases
- Relationships
- Result rows
- SQL interpolation
- Queries
- Filtering
- Joins
- Aggregation
- Paging and ordering
- Subqueries
- Set operations
- Common table expressions
- Readers
- Streaming
- Writers
- Inserts
- Updates
- Deletes
- Returned rows
- Custom SQL and procedures
- Transactions
- Resource lifetimes
- Database dialects
- Diagnostics
- Integrations
- Recipes
- Reference
- Troubleshooting
- Development