AxisResult.HttpResponse
2.2.0
dotnet add package AxisResult.HttpResponse --version 2.2.0
NuGet\Install-Package AxisResult.HttpResponse -Version 2.2.0
<PackageReference Include="AxisResult.HttpResponse" Version="2.2.0" />
<PackageVersion Include="AxisResult.HttpResponse" Version="2.2.0" />
<PackageReference Include="AxisResult.HttpResponse" />
paket add AxisResult.HttpResponse --version 2.2.0
#r "nuget: AxisResult.HttpResponse, 2.2.0"
#:package AxisResult.HttpResponse@2.2.0
#addin nuget:?package=AxisResult.HttpResponse&version=2.2.0
#tool nuget:?package=AxisResult.HttpResponse&version=2.2.0
AxisResult.HttpResponse — Documentation
The HTTP edge for AxisResult — one extension member on HttpContext turns an AxisResult / AxisResult<T> into an ASP.NET Core IActionResult, mapping every AxisErrorType to the right status code and rendering failures as RFC 7807 ProblemDetails (with the request traceId and internal errors suppressed).
// In a controller — one line maps success and every failure category
[HttpPost]
public Task<IActionResult> Create(CreatePersonCommand cmd)
=> HttpContext.SendAsync(
mediator.Cqrs.ExecuteAsync<CreatePersonCommand, CreatePersonResponse>(cmd),
HttpStatusCode.Created);
Use this page as a map: read the trunk below (~5 min) and jump straight to the detail you need.
The trunk (read first)
From AxisResult to HTTP in 60 seconds
Your handlers return an AxisResult / AxisResult<T>. The controller's only job is to render it. This package is that renderer:
AxisResult ──success──▶ StatusCodeResult (200, or your status)
│
AxisResult<T> ─success─▶ ObjectResult { Value, status } (204 → NoContentResult)
│
either ───────failure──▶ ObjectResult { ProblemDetails } (status from the error)
A single call, HttpContext.SendAsync, awaits your handler's task and collapses both rails into the correct HTTP response. → Convert · HttpContext.SendAsync
Success vs. failure
- Success, no value (
AxisResult) →StatusCodeResultwithstatusCode(default200 OK). - Success, with value (
AxisResult<T>) →ObjectResultcarryingValue;HttpStatusCode.NoContentyields a bodyless204. - Failure → an
ObjectResultwrapping aProblemDetails, whose status is chosen from the most severe error in the list.
Error → status, the short version
Each AxisErrorType maps to a status code; on a multi-error failure the highest-severity error wins, InternalServerError is never leaked into the payload, and the traceId always travels in extensions. → Error → status mapping
Installation
dotnet add package AxisResult.HttpResponse
Depends on AxisResult and targets ASP.NET Core (FrameworkReference Microsoft.AspNetCore.App) — add it to a web project. → Full guide: Getting started
The map (jump to what you need)
| Group | You want to… | Detail |
|---|---|---|
Convert · HttpContext.SendAsync ⭐ |
turn an AxisResult into an IActionResult |
send-http-response.md |
Reuse outside MVC · AxisProblemDetailsBuilder |
render the same ProblemDetails rule from middleware/filters, with no IActionResult |
problem-details-builder.md |
Mapping · AxisErrorType → status |
know which error becomes which status code | error-status-mapping.md |
| Why? | the case for a dedicated edge package | why-axisresult-httpresponse.md |
| Reference | every extension at a glance | api-reference.md |
Start here: Getting started · Convert · HttpContext.SendAsync · Why AxisResult.HttpResponse?
Fundamentals: Error → status mapping · ProblemDetails shape
Reference & extras: API reference
Design principles
- One line at the controller. Success and every failure category collapse into a single
HttpContext.SendAsynccall — notry/catch, no branch you can forget. - The error type chooses the status. Status codes are derived from
AxisErrorType, not hand-written per endpoint, so the mapping is consistent across the whole API. - Most-severe wins. A failure with many errors returns the status of the gravest one — a
ValidationRulenext to anInternalServerErroris a500, not a400. - Never leak internals.
InternalServerErrorentries are counted but stripped from the payload; clients see that something failed, not what. - Always traceable. The request
traceIdis taken fromHttpContext.TraceIdentifierautomatically — never passed by hand — and always rides along inProblemDetails.Extensions, so a client report ties straight back to your logs.
License
Apache 2.0
| 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
- AxisResult (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.