Trellis.Http
3.0.0-alpha.382
dotnet add package Trellis.Http --version 3.0.0-alpha.382
NuGet\Install-Package Trellis.Http -Version 3.0.0-alpha.382
<PackageReference Include="Trellis.Http" Version="3.0.0-alpha.382" />
<PackageVersion Include="Trellis.Http" Version="3.0.0-alpha.382" />
<PackageReference Include="Trellis.Http" />
paket add Trellis.Http --version 3.0.0-alpha.382
#r "nuget: Trellis.Http, 3.0.0-alpha.382"
#:package Trellis.Http@3.0.0-alpha.382
#addin nuget:?package=Trellis.Http&version=3.0.0-alpha.382&prerelease
#tool nuget:?package=Trellis.Http&version=3.0.0-alpha.382&prerelease
Trellis.Http
HttpClient extensions that bridge HttpResponseMessage into Result<T> / Result<Maybe<T>> pipelines.
Installation
dotnet add package Trellis.Http
What we provide (v3 surface)
A single static class Trellis.Http.HttpResponseExtensions with the canonical HTTP result methods:
ToResultAsync(statusMap?)— bridgeTask<HttpResponseMessage>intoTask<Result<HttpResponseMessage>>; without a map, non-2xx statuses become typed failures.ToResultAsync(mapper, ct)— body-aware bridge invoked only for non-success status codes.HandleNotFoundAsync/HandleConflictAsync/HandleUnauthorizedAsync— single-status convenience entry points onTask<HttpResponseMessage>.ReadJsonAsync<T>/ReadJsonMaybeAsync<T>— deserialize the body ofTask<Result<HttpResponseMessage>>intoTorMaybe<T>.ReadJsonOrNoneOn404Async<T>— terminal optional-resource read where404maps toOk(Maybe.None).
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);
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, OperationCanceledException / TaskCanceledException, and JsonException (from ReadJsonMaybeAsync<T> / ReadJsonOrNoneOn404Async<T> on a 2xx invalid body) propagate through the chain rather than being mapped to Result.Fail. ReadJsonAsync<T> catches JsonException and returns Fail<Error.Unexpected> with structured position diagnostics only (no response body, no JsonException.Path).
Breaking changes from v1
Trellis.Http has collapsed from 60+ overloads to a small canonical method set. Removed verbs: HandleForbidden*, HandleClientError*, HandleServerError*, EnsureSuccess/EnsureSuccessAsync, HandleFailureAsync<TContext>, and all sync / Result<HRM> / HttpResponseMessage-receiver overloads. Renamed verbs: ReadResultFromJsonAsync → ReadJsonAsync, ReadResultMaybeFromJsonAsync → ReadJsonMaybeAsync. See the package README on GitHub for the full migration table.
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
- Trellis.Core (>= 3.0.0-alpha.382)
- Trellis.Http.Abstractions (>= 3.0.0-alpha.382)
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.382 | 37 | 6/12/2026 |
| 3.0.0-alpha.372 | 47 | 6/10/2026 |
| 3.0.0-alpha.360 | 60 | 6/7/2026 |
| 3.0.0-alpha.342 | 48 | 6/5/2026 |
| 3.0.0-alpha.337 | 50 | 6/3/2026 |
| 3.0.0-alpha.336 | 47 | 6/3/2026 |
| 3.0.0-alpha.304 | 51 | 5/29/2026 |
| 3.0.0-alpha.158 | 66 | 4/5/2026 |
| 3.0.0-alpha.157 | 71 | 4/4/2026 |
| 3.0.0-alpha.140 | 69 | 3/30/2026 |
| 3.0.0-alpha.137 | 68 | 3/27/2026 |
| 3.0.0-alpha.135 | 57 | 3/26/2026 |
| 3.0.0-alpha.127 | 61 | 3/23/2026 |
| 3.0.0-alpha.123 | 63 | 3/19/2026 |
| 3.0.0-alpha.118 | 74 | 3/14/2026 |
| 3.0.0-alpha.111 | 71 | 3/12/2026 |
| 3.0.0-alpha.104 | 64 | 3/9/2026 |
| 3.0.0-alpha.100 | 55 | 3/4/2026 |
| 3.0.0-alpha.99 | 60 | 3/4/2026 |
| 3.0.0-alpha.98 | 64 | 3/3/2026 |