Koto.Api.FastEndpoints
0.3.0-preview.3
dotnet add package Koto.Api.FastEndpoints --version 0.3.0-preview.3
NuGet\Install-Package Koto.Api.FastEndpoints -Version 0.3.0-preview.3
<PackageReference Include="Koto.Api.FastEndpoints" Version="0.3.0-preview.3" />
<PackageVersion Include="Koto.Api.FastEndpoints" Version="0.3.0-preview.3" />
<PackageReference Include="Koto.Api.FastEndpoints" />
paket add Koto.Api.FastEndpoints --version 0.3.0-preview.3
#r "nuget: Koto.Api.FastEndpoints, 0.3.0-preview.3"
#:package Koto.Api.FastEndpoints@0.3.0-preview.3
#addin nuget:?package=Koto.Api.FastEndpoints&version=0.3.0-preview.3&prerelease
#tool nuget:?package=Koto.Api.FastEndpoints&version=0.3.0-preview.3&prerelease
Koto.Api.FastEndpoints
FastEndpoints integration for Koto DDD building blocks. Builds on
Koto.Api.AspNetCore (transport-agnostic Result→HTTP mapping, KotoProblemDetails,
KotoHttpErrorOptions).
What's included
| Type | Purpose |
|---|---|
CommandEndpoint<TCommand> |
Dispatches void command → 204 on success, Problem Details on failure |
CommandEndpoint<TCommand, TResult> |
Dispatches result command → 200 on success |
QueryEndpoint<TQuery, TResult> |
Dispatches query → 200 / 404 / 400 |
MappedCommandEndpoint<TRequest, TCommand[, TResult]> |
Maps an HTTP request DTO to a command via ToCommand — keeps server-derived fields out of the wire contract |
MappedQueryEndpoint<TRequest, TQuery, TResult> |
Maps an HTTP request DTO to a query via ToQuery |
ClaimsPrincipalExtensions.GetUserId() |
Reads the user id from the NameIdentifier claim (TryGetUserId for the no-throw path) |
CorrelationIdMiddleware |
Reads/generates X-Correlation-ID, echoes in response |
ICorrelationIdAccessor |
Access current correlation ID from anywhere in the request scope |
GlobalExceptionHandler |
Catches unhandled exceptions → 500 Problem Details |
Failed results are rendered by KotoProblemDetails from Koto.Api.AspNetCore —
all Result.Errors are sent (multiple errors become RFC 7807 validation problem
details grouped by Error.Field), with errorCode/errorCodes and correlationId extensions.
Setup
// Program.cs
builder.Services.AddKotoApi(); // includes AddKotoAspNetCore()
// Or customize the Error.Code → HTTP status registry:
builder.Services.AddKotoApi(o => o.Map("payments.gateway-failed", 502));
builder.Services.AddFastEndpoints();
// ... other services
var app = builder.Build();
app.UseKotoApi(); // CorrelationId middleware + exception handler
app.UseFastEndpoints();
app.Run();
Implementing an endpoint
// Void command (204 on success)
public class DeleteOrderEndpoint : CommandEndpoint<DeleteOrderCommand>
{
public override void Configure()
{
Delete("/orders/{id}");
AllowAnonymous();
}
public override async Task HandleAsync(DeleteOrderCommand req, CancellationToken ct)
=> await SendCommandAsync(req, ct);
}
// Command with result (200 on success)
public class PlaceOrderEndpoint : CommandEndpoint<PlaceOrderCommand, OrderId>
{
public override void Configure()
{
Post("/orders");
AllowAnonymous();
}
public override async Task HandleAsync(PlaceOrderCommand req, CancellationToken ct)
=> await SendCommandAsync(req, ct);
}
// Query (GET, 200/404)
public class GetOrderEndpoint : QueryEndpoint<GetOrderQuery, OrderDto>
{
public override void Configure()
{
Get("/orders/{id}");
AllowAnonymous();
}
public override async Task HandleAsync(GetOrderQuery req, CancellationToken ct)
=> await SendQueryAsync(req, ct);
}
Server-derived fields (claims, route, tenant)
When a command/query carries fields that must come from the server (the caller's user id, tenant,
correlation id) and must not be bindable from the request body, use the mapped endpoints. The
request DTO omits those fields; ToCommand/ToQuery builds the command from the request and the
endpoint context (User, Route<T>(), headers):
public sealed record SubmitJudgmentRequest(Guid SubmissionId, int GoeScore); // no JudgeId on the wire
public sealed record SubmitJudgmentCommand(Guid JudgeId, Guid SubmissionId, int GoeScore) : ICommand<Judgment>;
public sealed class SubmitJudgmentEndpoint
: MappedCommandEndpoint<SubmitJudgmentRequest, SubmitJudgmentCommand, Judgment>
{
public override void Configure() { Post("/api/v1/judgments"); Policies("IsJudge"); }
protected override SubmitJudgmentCommand ToCommand(SubmitJudgmentRequest r) =>
new(JudgeId: User.GetUserId(), r.SubmissionId, r.GoeScore); // JudgeId from claims, not the body
}
Prefer the plain CommandEndpoint/QueryEndpoint when the request is the command (no server-derived
fields). HandleAsync is sealed on the mapped variants — you only implement Configure and ToCommand/ToQuery.
Error code → HTTP status mapping
Status codes come from KotoHttpErrorOptions (Koto.Api.AspNetCore) — an extensible
registry (exact code → custom rules → suffix → prefix → fallback). Defaults:
| Error code pattern | Status |
|---|---|
*.not-found |
404 Not Found |
*.already-*, *.conflict |
409 Conflict |
*.unauthorized |
401 Unauthorized |
*.forbidden |
403 Forbidden |
general.*, validation.*, Error.Field != null |
400 Bad Request |
| anything else | 422 Unprocessable Entity (configurable fallback; 500 is reserved for unhandled exceptions) |
Customize via AddKotoApi(o => o.Map("subscription.payment-failed", 502)).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FastEndpoints (>= 5.35.0)
- Koto.Api.AspNetCore (>= 0.3.0-preview.3)
- Koto.Application (>= 0.3.0-preview.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.0-preview.3 | 43 | 7/11/2026 |
| 0.3.0-preview.2 | 47 | 7/11/2026 |
| 0.3.0-preview.1 | 52 | 7/3/2026 |
| 0.2.0-preview.1 | 65 | 6/28/2026 |
| 0.1.0-preview.5 | 65 | 5/13/2026 |
| 0.1.0-preview.4 | 63 | 5/13/2026 |