Trellis.Http 3.0.0-alpha.574

This is a prerelease version of Trellis.Http.
dotnet add package Trellis.Http --version 3.0.0-alpha.574
                    
NuGet\Install-Package Trellis.Http -Version 3.0.0-alpha.574
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Trellis.Http" Version="3.0.0-alpha.574" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Trellis.Http" Version="3.0.0-alpha.574" />
                    
Directory.Packages.props
<PackageReference Include="Trellis.Http" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Trellis.Http --version 3.0.0-alpha.574
                    
#r "nuget: Trellis.Http, 3.0.0-alpha.574"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Trellis.Http@3.0.0-alpha.574
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Trellis.Http&version=3.0.0-alpha.574&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Trellis.Http&version=3.0.0-alpha.574&prerelease
                    
Install as a Cake Tool

Trellis.Http

NuGet Package

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

  • ToResultAsync maps HTTP status codes into typed Trellis results.
  • HandleNotFoundAsync, HandleConflictAsync, and HandleUnauthorizedAsync cover common expected failures.
  • ReadJsonAsync<T> and ReadJsonMaybeAsync<T> deserialize required and optional bodies.
  • ReadJsonOrNoneOn404Async<T> maps a missing upstream resource to Maybe.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed