Trellis.Http
3.0.0-alpha.574
dotnet add package Trellis.Http --version 3.0.0-alpha.574
NuGet\Install-Package Trellis.Http -Version 3.0.0-alpha.574
<PackageReference Include="Trellis.Http" Version="3.0.0-alpha.574" />
<PackageVersion Include="Trellis.Http" Version="3.0.0-alpha.574" />
<PackageReference Include="Trellis.Http" />
paket add Trellis.Http --version 3.0.0-alpha.574
#r "nuget: Trellis.Http, 3.0.0-alpha.574"
#:package Trellis.Http@3.0.0-alpha.574
#addin nuget:?package=Trellis.Http&version=3.0.0-alpha.574&prerelease
#tool nuget:?package=Trellis.Http&version=3.0.0-alpha.574&prerelease
Trellis.Http
HttpClient extensions that bridge HttpResponseMessage into Result<T> / Result<Maybe<T>> pipelines.
Installation
dotnet add package Trellis.Http
Quick Example
using System.Text.Json.Serialization;
using Trellis;
using Trellis.Http;
public sealed record ProfileDto(string DisplayName);
[JsonSerializable(typeof(ProfileDto))]
public partial class ProfileJsonContext : JsonSerializerContext { }
var userId = "current-user";
var result = await httpClient.GetAsync("/profile", cancellationToken)
.HandleNotFoundAsync(new Error.NotFound(ResourceRef.For("Profile", userId)))
.ReadJsonAsync(ProfileJsonContext.Default.ProfileDto, cancellationToken);
Key Features
ToResultAsyncmaps HTTP status codes into typed Trellis results.HandleNotFoundAsync,HandleConflictAsync, andHandleUnauthorizedAsynccover common expected failures.ReadJsonAsync<T>andReadJsonMaybeAsync<T>deserialize required and optional bodies.ReadJsonOrNoneOn404Async<T>maps a missing upstream resource toMaybe.None.- Terminal
ReadJson*operations own response disposal; pass-through operations leave it with the caller.
Disposal contract
The library owns HttpResponseMessage disposal on terminal/transformative paths: ToResultAsync and Handle*Async dispose on the Fail path; ReadJson* always dispose after reading. Pass-through paths leave disposal to the caller. Programmer-error null-argument paths (e.g. client.GetAsync(...).HandleNotFoundAsync(null!)) await first, then dispose before throwing ArgumentNullException.
Strict-default behavior
ToResultAsync() without a statusMap produces typed errors with HTTP-specific cases wrapped in Error.TransportFault(new HttpError.*(...)). The strict default preserves Allow on 405 and Content-Range on 416. 401 does not carry parsed WWW-Authenticate challenges, and 429 / 503 do not preserve Retry-After into the error payload. Missing or unusable header values for 405 and 416 fall through to Error.Unexpected rather than fabricating misleading wire headers. 3xx responses fall through; redirect-aware callers should pass a statusMap.
Exception propagation
HttpRequestException and OperationCanceledException / TaskCanceledException propagate through the chain rather than being mapped to Result.Fail. JsonException does not: ReadJsonAsync<T>, ReadJsonMaybeAsync<T>, and ReadJsonOrNoneOn404Async<T> all catch it and return Fail<Error.Unexpected> (Code = FaultCodes.HttpResponseInvalidBody) with structured position diagnostics only (no response body, no JsonException.Path).
Documentation
Part of Trellis
This package is part of the Trellis framework.
| 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
- OpenTelemetry.Api (>= 1.19.1)
- Trellis.Core (>= 3.0.0-alpha.574)
- Trellis.Http.Abstractions (>= 3.0.0-alpha.574)
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 |
|---|---|---|
| 3.0.0-alpha.574 | 45 | 10/14/2026 |
| 3.0.0-alpha.571 | 40 | 10/13/2026 |
| 3.0.0-alpha.557 | 50 | 10/8/2026 |
| 3.0.0-alpha.554 | 50 | 10/8/2026 |
| 3.0.0-alpha.553 | 47 | 10/7/2026 |
| 3.0.0-alpha.542 | 58 | 10/5/2026 |
| 3.0.0-alpha.539 | 58 | 10/4/2026 |
| 3.0.0-alpha.532 | 54 | 10/2/2026 |
| 3.0.0-alpha.527 | 56 | 10/1/2026 |
| 3.0.0-alpha.526 | 53 | 9/30/2026 |
| 3.0.0-alpha.524 | 59 | 9/27/2026 |
| 3.0.0-alpha.520 | 60 | 9/25/2026 |
| 3.0.0-alpha.516 | 151 | 9/22/2026 |
| 3.0.0-alpha.513 | 65 | 9/22/2026 |
| 3.0.0-alpha.505 | 66 | 9/13/2026 |
| 3.0.0-alpha.495 | 130 | 8/24/2026 |
| 3.0.0-alpha.458 | 108 | 8/19/2026 |
| 3.0.0-alpha.455 | 135 | 8/19/2026 |
| 3.0.0-alpha.449 | 70 | 8/18/2026 |
| 3.0.0-alpha.447 | 82 | 8/18/2026 |