Part of DKNet.AspCore.Extensions. The fluent mappers on RouteGroupBuilder resolve IMessageBus and dispatch the bound request. Register a bus and matching handlers in the host before serving these endpoints. This complete mapping example declares a command; it prints the endpoint name without dispatching it:
using DKNet.AspCore.Extensions.Endpoints;
using DKNet.SlimBus.Extensions;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var group = app.MapGroup("/orders");
group.MapPost<CreateOrder, OrderModel>("/").WithName("CreateOrder");
Console.WriteLine("CreateOrder mapped; register IMessageBus and its handler before serving.");
public sealed record CreateOrder : Fluents.Requests.IWitResponse<OrderModel>;
public sealed record OrderModel(Guid Id);
| Mapper | Contract and binding | Success |
|---|---|---|
MapGet<TCommand,TResponse> |
Fluents.Queries.IWitResponse<TResponse>, [AsParameters] |
200 value, 404 for null. |
MapGetPage<TCommand,TResponse> |
Fluents.Queries.IWitPageResponse<TResponse>, [AsParameters] |
200 PagedResponse<TResponse>. |
MapPost<TCommand,TResponse> / MapPost<TCommand> |
Fluents.Requests.IWitResponse<TResponse> / INoResponse, inferred body |
201 if type name contains Create case-insensitively; otherwise 200. |
MapPut / MapPatch, with or without response |
Same request contracts, inferred body | 200. |
MapDelete<TCommand,TResponse> |
Response request, explicit [FromBody] |
200. |
MapDelete<TCommand> |
No-response request, [AsParameters] |
200. |
MapPutById<TCommand,TKey,TResponse> |
Response request plus IWithKey<TKey>, body and route id |
200; default route {id}. |
MapActionById<TCommand,TKey,TResponse> |
Same key contract; supplied route and verb, required body | 200. |
MapParameterlessActionById<TCommand,TKey,TResponse> |
Same contracts plus new(); supplied route and verb, no body binding |
200. |
By-ID forms assign the route value to request.Id before sending. Parameterless actions construct the command and ignore any supplied body; other members keep their defaults. Every mapper adds ProducesCommons(): standard error response metadata and an endpoint exception filter. You can also apply it to a hand-written route.
Use SlimBus Extensions to register the bus/handler pipeline. Entity-only reads and deletes can instead use repository mappers. The overview’s component diagram shows these alternative dispatch paths.
IMessageBus or handler configuration fails at runtime./ for valued results.