You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's it. The source generator discovers handlers by naming convention at compile time — zero registration, zero reflection, near-direct-call performance.
58
+
59
+
### Generate API endpoints
60
+
61
+
Handlers can automatically become API endpoints. Return `Result<T>` for rich HTTP status mapping:
Routes, HTTP methods, parameter binding, and OpenAPI metadata are all inferred from your message names and `Result` factory calls.
87
+
32
88
**👉 [Getting Started Guide](https://mediator.foundatio.dev/guide/getting-started.html)** — step-by-step setup with code samples for ASP.NET Core and console apps.
Copy file name to clipboardExpand all lines: docs/guide/endpoints.md
+56-1Lines changed: 56 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,7 +240,7 @@ The HTTP method is inferred from the message type name prefix:
240
240
|`Delete*`, `Remove*`| DELETE |
241
241
|`Patch*`| PATCH |
242
242
243
-
**Action verbs** — prefixes like `Complete*`, `Approve*`, `Cancel*`, `Submit*`, `Archive*`, `Publish*`, etc., default to **POST** and produce an action route suffix:
243
+
**Action verbs** — prefixes like `Complete*`, `Approve*`, `Cancel*`, `Submit*`, `Archive*`, `Publish*`, `Export*`, `Import*`, `Download*`, `Upload*`, etc., default to **POST** and produce an action route suffix:
244
244
245
245
```csharp
246
246
// POST /api/todos/{todoId}/complete
@@ -341,6 +341,61 @@ To override auto-pluralization, use an explicit route:
341
341
publicResult<Item>Handle(GetItemquery) { ... }
342
342
```
343
343
344
+
### Message Naming Conventions
345
+
346
+
Routes are derived from the **message type name**. The generator strips a verb prefix, normalizes common qualifiers, pluralizes the entity, and converts to kebab-case. Understanding this pipeline helps you write message names that produce clean, consistent routes.
347
+
348
+
**The golden path** — these naming patterns produce RESTful routes automatically:
349
+
350
+
```csharp
351
+
publicrecordGetTodo(stringId); // → GET /api/todos/{id}
352
+
publicrecordGetTodos(); // → GET /api/todos
353
+
publicrecordCreateTodo(stringName); // → POST /api/todos
354
+
publicrecordUpdateTodo(stringId); // → PUT /api/todos/{id}
publicrecordCompleteTodo(stringId); // → POST /api/todos/{id}/complete
357
+
publicrecordExportTodos(); // → POST /api/todos/export
358
+
```
359
+
360
+
**Common qualifiers are normalized automatically.** The generator handles a variety of CQRS naming conventions, extracting the entity name and producing clean routes:
**Converted to route segments** (distinct sub-resources): `By<Property>`, `For<Entity>`, `From<Entity>`, `Count`
378
+
379
+
**Action prefixes** (produce POST with action suffix): `Complete`, `Approve`, `Cancel`, `Submit`, `Export`, `Import`, `Download`, `Upload`, and [others](./handler-conventions.md)
380
+
381
+
::: tip
382
+
`By<Property>`, `For<Entity>`, and `From<Entity>` produce route segments under the entity, keeping all routes grouped. For example, `GetTodoByName(string Name)` generates `GET /api/todos/by-name?name=...` — no conflict with the list route `GET /api/todos`.
383
+
:::
384
+
385
+
**What to avoid.** Message names that don't reduce to a common entity will produce separate routes. If you see unexpected routes, check your message names:
386
+
387
+
```csharp
388
+
// ❌ These produce different route prefixes — probably not what you want
The generator emits diagnostic **FMED016** when handlers in the same class produce routes with different base paths, alerting you to naming inconsistencies. Use `[HandlerEndpointGroup("Todos")]` to force a shared prefix when message names don't naturally align.
398
+
344
399
### Route Parameters
345
400
346
401
Properties named `Id` or ending with `Id` automatically become route parameters:
Copy file name to clipboardExpand all lines: docs/guide/getting-started.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ This generates:
105
105
106
106
<!---->
107
107
108
-
HTTP methods, routes, and parameter binding are all inferred from message names and properties. See [Endpoints](./endpoints) for route customization, OpenAPI metadata, authorization, and more.
108
+
HTTP methods, routes, and parameter binding are all inferred from message names and properties. Routes derive from the message name, are auto-pluralized, and common qualifiers like `All` and `ById` are normalized. See [Endpoints](./endpoints) for route customization, naming conventions, and more.
0 commit comments