Minimal API friendly version of `MapWhen`
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
When using `MapWhen` we get a lot of nesting:
```cs
app.MapWhen(ctx => ..., appBuilder =>
{
appBuilder.UseRouting();
appBuilder.UseEndpoints(routeBuilder =>
{
routeBuilder.MapGet(...);
});
}
app.MapWhen(ctx => ..., appBuilder =>
{
appBuilder.UseRouting();
appBuilder.UseCors();
appBuilder.UseEndpoints(routeBuilder =>
{
routeBuilder.MapPost(...);
});
}
```
### Describe the solution you'd like
It would be nice if we had a top-level API, for example:
```cs
var app1 = app.MapBranch(ctx => ...);
app1.UseRouting();
app1.MapGet(...);
var app2 = app.MapBranch(ctx => ...);
app2.UseRouting();
app2.UseCors();
app2.MapPost(...);
```
`MapBranch` can return a new type implementing both `IApplicationBuilder` and `IRouteEndpointBuilder`.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.