dotnet / dotnet/aspnetcore

[Route Groups] Implement IApplicationBuilder to support grouped middleware

Open
#41,431 1 comment 0 reactions 0 assignees View on GitHub
area-minimal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

We want `MapGroup` to support middleware via the `IApplicationBuilder` interface so things like `UseResponseCompression()`, `UseHttpLogging()`, `UseForwardedHeaders()`, `UseRequestLocalization()`, terminal middleware like `UseStaticFiles()` and [more](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0#built-in-middleware) can be called on a group.

### Describe the solution you'd like

This still needs design, but there are a lot of open questions. We still need to figure out how we define a middleware that runs every time a route handler in a given group is hit. before running the endpoint and similar middleware from inner groups?

- How do we deal with middleware that checks the request path?
- Can we trim the group prefix from the path?
- What about middleware that's aware of grouping and wants the real full path?
- Do we add a new feature to support this?
- Can middleware use default endpoint metadata (#41429) to infer the real full path?
- What if no endpoint is matched, but the middleware would have been terminal?
- Do we create a low-priority catchall endpoint with the route prefix?
- Then what if the middleware isn't terminal?
- Can we still fallback to the normal missing endpoint logic if we add a fake catchall endpoint?
- Will we support middleware rewriting the route after matching a specific group prefix and rerun routing?
- This seems like too much. What if the new

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.