[Route Groups] Investigate callback based API #41432
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Milestone
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
A callback-based version of
MapGroup
was considered as an [alternative design in the original route grouping issue. In this design, theIEndpointRouteBuilder
would be passed to a callback rather than returned fromMapGroup
.Describe the solution you'd like
If we use callbacks instead of the return type of
MapGroup
to define endpoints, it naturally leads to a nested structure in the cod that matches the nested structure of a group. For example:So instead of what we have today:
You an already manually introduce scopes to get a similar kind of structure with the existing API as demonstrated by https://twitter.com/davidfowl/status/1519480212060139521, but I doubt many people will structure their code like this in practice unless we use callbacks:
Additional context
The current API and a callback-based API are not mutually exclusive. These are different overloads, so both could be supported. I don't like this however, because I think having too many ways to do things does more harm by creating confusion than it helps by providing more flexibility.
If we do decide to support both, we'd need to decide would
MapGroup
still return aGroupRouteBuilder
that you can add endpoints on? And would the callback parameter also be aGroupRouteBuilder
meaning you could add both routes and conventions both inside and outside the callback? In our docs, would we normally add endpoints inside the callback and conventions outside the callback like in the sample above?The text was updated successfully, but these errors were encountered: