Vostra.Result.AspNetCore
1.2.1
dotnet add package Vostra.Result.AspNetCore --version 1.2.1
NuGet\Install-Package Vostra.Result.AspNetCore -Version 1.2.1
<PackageReference Include="Vostra.Result.AspNetCore" Version="1.2.1" />
<PackageVersion Include="Vostra.Result.AspNetCore" Version="1.2.1" />
<PackageReference Include="Vostra.Result.AspNetCore" />
paket add Vostra.Result.AspNetCore --version 1.2.1
#r "nuget: Vostra.Result.AspNetCore, 1.2.1"
#:package Vostra.Result.AspNetCore@1.2.1
#addin nuget:?package=Vostra.Result.AspNetCore&version=1.2.1
#tool nuget:?package=Vostra.Result.AspNetCore&version=1.2.1
Vostra.Result.AspNetCore
ASP.NET Core HTTP mapping for Vostra.Result: turn a
Result/Result<T> into an HTTP response with one extension method. Works in minimal APIs and MVC
controllers — no base class.
Install
dotnet add package Vostra.Result.AspNetCore
Setup (optional)
The whole point: your error kinds already know what they mean, so the HTTP layer shouldn't repeat that in a
central switch. ToHttpResponse reads the status from the error itself and works with sensible defaults
out of the box — call AddVostraResults only when you want to override the map:
builder.Services.AddVostraResults(o =>
{
o.MapStatus(ErrorType.Conflict, 422); // override a whole ErrorType
o.MapStatusForCode("Order.Locked", 423); // override one error code
});
Precedence: per-Code override → per-ErrorType map → built-in default.
| ErrorType | Default status |
|---|---|
| Validation | 400 |
| Unauthorized | 401 |
| Forbidden | 403 |
| NotFound | 404 |
| Conflict | 409 |
| Unexpected | 500 |
A new ErrorBase subclass maps automatically through its ErrorType — no mapping edits.
Usage
Endpoints stay one line — return the Result and let the mapping pick the status, body, and pagination.
Same call in minimal APIs and controllers, no base class:
// minimal API
app.MapGet("/orders/{id}", (int id, HttpContext http, IOrderService svc) =>
svc.Get(id).ToHttpResponse(http));
// controller
[HttpGet("{id}")]
public async Task<IResult> Get(int id) =>
(await _svc.Get(id)).ToHttpResponse(HttpContext);
// paginated list
app.MapGet("/orders", (HttpContext http, IOrderService svc) =>
svc.List().ToHttpResponse(http, new Pagination(page: 1, pageSize: 20, totalCount: 137)));
Wire shapes
Success bodies stay thin (just a correlation id + your data); failures are standard ProblemDetails that
keep the error's identity on the wire — which is exactly what lets the testing package reconstruct the
typed error later.
Success (SuccessKind.Ok → 200, Created → 201):
{ "operationId": "00-abc…-01", "data": { "id": 42 } }
List:
{ "operationId": "…", "data": [ … ],
"pagination": { "page": 1, "pageSize": 20, "totalCount": 137, "totalPages": 7 } }
Error — RFC 7807 application/problem+json, carrying code + errorType so a test client can assert on
typed-error identity:
{ "type": "about:blank", "title": "Not Found", "status": 404,
"detail": "Order 42 not found", "code": "Order.NotFound", "errorType": "NotFound",
"operationId": "…" }
Validation errors (all ErrorType.Validation) render a field → messages map (field key =
metadata["field"] if present, else the error Code):
{ "status": 400, "code": "General.Validation", "errorType": "Validation",
"errors": { "Sku": ["required"], "Price": ["must be > 0"] }, "operationId": "…" }
Migration from a { status, operationId, data } envelope
- Success bodies drop
status(read the HTTP status line); error bodies keep it (RFC 7807). operationIdis a W3C trace id (Activity.Current?.Id ?? HttpContext.TraceIdentifier).- Lists use
ToHttpResponse(http, Pagination)with this package'sPaginationrecord.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Vostra.Result (>= 1.2.1)
-
net8.0
- Vostra.Result (>= 1.2.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Vostra.Result.AspNetCore:
| Package | Downloads |
|---|---|
|
Vostra.Result.AspNetCore.Testing
HTTP integration-testing toolkit for Vostra.Result — a TestHttpClient returning Result<T> with typed-error reconstruction over the Vostra.Result.AspNetCore response contract. |
GitHub repositories
This package is not used by any popular GitHub repositories.