Skip to content

Commit 2f12fc6

Browse files
committed
HandlerCategory renamed to HandlerEndpointGroup
1 parent e59123b commit 2f12fc6

File tree

17 files changed

+436
-568
lines changed

17 files changed

+436
-568
lines changed

docs/guide/clean-architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The mediator pattern is the perfect complement to Clean Architecture because it
6666
With Foundatio Mediator's source generator, you can **eliminate the presentation layer boilerplate entirely**. HTTP endpoints are automatically generated from your handlers:
6767

6868
```csharp
69-
[HandlerCategory("Orders", RoutePrefix = "/api/orders")]
69+
[HandlerEndpointGroup("Orders", RoutePrefix = "/api/orders")]
7070
public class OrderHandler
7171
{
7272
/// <summary>
@@ -388,7 +388,7 @@ public class OrdersController : ControllerBase
388388
}
389389

390390
// Foundatio Mediator - handlers ARE the API
391-
[HandlerCategory("Orders", RoutePrefix = "/api/orders")]
391+
[HandlerEndpointGroup("Orders", RoutePrefix = "/api/orders")]
392392
public class OrderHandler
393393
{
394394
public async Task<Result<Order>> HandleAsync(CreateOrder cmd, IOrderRepository repo, CancellationToken ct)

docs/guide/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ The following properties on `MediatorConfigurationAttribute` control endpoint ge
170170
- **Default:** `All`
171171
- **Effect:** Controls which handlers generate API endpoints
172172
- `All`: All handlers with endpoint-compatible message types generate endpoints (default). Use `[HandlerEndpoint(Exclude = true)]` to opt out individual handlers.
173-
- `Explicit`: Only handlers with `[HandlerEndpoint]` or `[HandlerCategory]` attribute generate endpoints
173+
- `Explicit`: Only handlers with `[HandlerEndpoint]` or `[HandlerEndpointGroup]` attribute generate endpoints
174174
- `None`: No endpoints generated
175175
- **See:** [Endpoints Guide](/guide/endpoints) for full documentation
176176

177177
**`EndpointRoutePrefix`** (`string?`)
178178

179179
- **Default:** `"api"`
180-
- **Effect:** Sets a global route prefix that all category groups nest under. Categories auto-derive their route from their name (e.g., `[HandlerCategory("Products")]``products`), composing with the global prefix to produce `/api/products`.
180+
- **Effect:** Sets a global route prefix that all category groups nest under. Categories auto-derive their route from their name (e.g., `[HandlerEndpointGroup("Products")]``products`), composing with the global prefix to produce `/api/products`.
181181
- **Important:** Category-level `RoutePrefix` values without a leading `/` are **relative** to this global prefix. Don't include `api` in your category prefixes when using the default global prefix, or you'll get `/api/api/...`. Use a leading `/` on a category prefix to make it absolute (bypasses the global prefix).
182182
- **To disable:** Set `EndpointRoutePrefix = ""` to remove the global prefix entirely, then use full paths in category prefixes.
183183

docs/guide/endpoints.md

Lines changed: 309 additions & 510 deletions
Large diffs are not rendered by default.

docs/guide/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public class LoggingMiddleware
370370
| `FMED011` | Error | Multiple Execute methods in a middleware class. Only one Execute/ExecuteAsync method is allowed per middleware class. |
371371
| `FMED012` | Warning | Circular ordering dependency detected between middleware or handlers using `OrderBefore`/`OrderAfter`. Falls back to numeric `Order`. |
372372
| `FMED014` | Warning | GET/DELETE endpoint message type has no parameterless constructor and no route/query parameters. |
373-
| `FMED015` | Warning | `HandlerCategory` `RoutePrefix` starts with the global `EndpointRoutePrefix`, producing a doubled path (e.g. `/api/api/...`). |
373+
| `FMED015` | Warning | `HandlerEndpointGroup` `RoutePrefix` starts with the global `EndpointRoutePrefix`, producing a doubled path (e.g. `/api/api/...`). |
374374

375375
## Getting Help
376376

samples/CleanArchitectureSample/src/Common.Module/Filters/SetRequestedByFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Common.Module.Filters;
1717
/// Wire this filter at any level of the three-tier hierarchy:
1818
/// <list type="bullet">
1919
/// <item><description>Global: <c>[assembly: MediatorConfiguration(EndpointFilters = [typeof(SetRequestedByFilter)])]</c></description></item>
20-
/// <item><description>Category: <c>[HandlerCategory("Orders", EndpointFilters = [typeof(SetRequestedByFilter)])]</c></description></item>
20+
/// <item><description>Group: <c>[HandlerEndpointGroup("Orders", EndpointFilters = [typeof(SetRequestedByFilter)])]</c></description></item>
2121
/// <item><description>Endpoint: <c>[HandlerEndpoint(EndpointFilters = [typeof(SetRequestedByFilter)])]</c></description></item>
2222
/// </list>
2323
/// </summary>

samples/CleanArchitectureSample/src/Common.Module/Handlers/HealthHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Common.Module.Handlers;
1212
/// monitors, and readiness probes.
1313
/// </summary>
1414
[HandlerAllowAnonymous]
15-
[HandlerCategory("Health")]
15+
[HandlerEndpointGroup("Health")]
1616
public class HealthHandler
1717
{
1818
public HealthStatusResponse Handle(GetHealthStatus query) =>

samples/CleanArchitectureSample/src/Orders.Module/Handlers/OrderHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Orders.Module.Handlers;
1515
/// Following Clean Architecture, this handler orchestrates use cases
1616
/// and delegates persistence to the IOrderRepository abstraction.
1717
/// </summary>
18-
[HandlerCategory("Orders", EndpointFilters = [typeof(SetRequestedByFilter)])]
18+
[HandlerEndpointGroup("Orders", EndpointFilters = [typeof(SetRequestedByFilter)])]
1919
public class OrderHandler(IOrderRepository repository)
2020
{
2121
/// <summary>

samples/CleanArchitectureSample/src/Products.Module/Handlers/ProductHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Products.Module.Handlers;
1414
/// Following Clean Architecture, this handler orchestrates use cases
1515
/// and delegates persistence to the IProductRepository abstraction.
1616
/// </summary>
17-
[HandlerCategory("Products")]
17+
[HandlerEndpointGroup("Products")]
1818
public class ProductHandler(IProductRepository repository)
1919
{
2020
/// <summary>

samples/CleanArchitectureSample/src/Reports.Module/Handlers/ReportHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Reports.Module.Handlers;
1414
/// - All data is fetched via published queries through the mediator
1515
/// - Loose coupling enables independent module evolution
1616
/// </summary>
17-
[HandlerCategory("Reports")]
17+
[HandlerEndpointGroup("Reports")]
1818
public class ReportHandler(IMediator mediator, ILogger<ReportHandler> logger)
1919
{
2020
private const int LowStockThreshold = 10;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace Foundatio.Mediator;
2+
3+
/// <summary>
4+
/// Specifies the HTTP method for a generated endpoint.
5+
/// </summary>
6+
public enum EndpointHttpMethod
7+
{
8+
/// <summary>
9+
/// The HTTP method is inferred from the message type name prefix
10+
/// (e.g., Get* → GET, Create* → POST, Update* → PUT, Delete* → DELETE, Patch* → PATCH).
11+
/// </summary>
12+
Default = 0,
13+
14+
/// <summary>
15+
/// HTTP GET — used for queries and read operations.
16+
/// </summary>
17+
Get = 1,
18+
19+
/// <summary>
20+
/// HTTP POST — used for commands that create resources or trigger actions.
21+
/// </summary>
22+
Post = 2,
23+
24+
/// <summary>
25+
/// HTTP PUT — used for commands that replace or fully update a resource.
26+
/// </summary>
27+
Put = 3,
28+
29+
/// <summary>
30+
/// HTTP DELETE — used for commands that remove a resource.
31+
/// </summary>
32+
Delete = 4,
33+
34+
/// <summary>
35+
/// HTTP PATCH — used for commands that partially update a resource.
36+
/// </summary>
37+
Patch = 5
38+
}

0 commit comments

Comments
 (0)