Trellis.Http 3.0.0-alpha.95

This is a prerelease version of Trellis.Http.
dotnet add package Trellis.Http --version 3.0.0-alpha.95
                    
NuGet\Install-Package Trellis.Http -Version 3.0.0-alpha.95
                    
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.95" />
                    
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.95" />
                    
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.95
                    
#r "nuget: Trellis.Http, 3.0.0-alpha.95"
                    
#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.95
                    
#: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.95&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Trellis.Http&version=3.0.0-alpha.95&prerelease
                    
Install as a Cake Tool

HTTP Client Extensions

NuGet Package

Fluent HTTP client extensions for Railway Oriented Programming — handle status codes, deserialize JSON, and compose error handling with Result<T> and Maybe<T>.

Installation

dotnet add package Trellis.Http

Quick Start

using Trellis;
using Trellis.Http;

var result = await httpClient.GetAsync($"api/users/{userId}", ct)
    .HandleNotFoundAsync(Error.NotFound("User not found", userId))
    .ReadResultFromJsonAsync(UserJsonContext.Default.User, ct);

// result is Result<User> — either Success with User or Failure with NotFoundError

Status Code Handlers

var response = await httpClient.PostAsync("api/orders", content, ct);
var result = await response
    .HandleUnauthorized(Error.Unauthorized("Please login"))
    .HandleForbidden(Error.Forbidden("Admin access required"))
    .HandleConflict(Error.Conflict("Order already exists"))
    .HandleClientError(code => Error.BadRequest($"Client error: {code}"))
    .HandleServerError(code => Error.ServiceUnavailable($"Server error: {code}"))
    .ReadResultFromJsonAsync(OrderJsonContext.Default.Order, ct);
Handler HTTP Status Error Type
HandleNotFoundAsync 404 NotFoundError
HandleUnauthorizedAsync 401 UnauthorizedError
HandleForbiddenAsync 403 ForbiddenError
HandleConflictAsync 409 ConflictError
HandleClientErrorAsync 4xx Custom via factory
HandleServerErrorAsync 5xx Custom via factory
EnsureSuccessAsync Any non-success Custom via factory

ROP Pipeline Integration

var result = await httpClient.GetAsync($"api/products/{productId}", ct)
    .HandleNotFoundAsync(Error.NotFound("Product", productId))
    .ReadResultFromJsonAsync(ProductJsonContext.Default.Product, ct)
    .EnsureAsync(p => p.IsAvailable, Error.Conflict("Product unavailable"))
    .TapAsync(p => _logger.LogInformation("Retrieved: {Name}", p.Name))
    .MapAsync(p => new ProductViewModel(p));

JSON Deserialization

// Required value — null response returns error
Task<Result<T>> ReadResultFromJsonAsync<T>(jsonTypeInfo, ct)

// Optional value — null response returns Maybe.None
Task<Result<Maybe<T>>> ReadResultMaybeFromJsonAsync<T>(jsonTypeInfo, ct)

License

MIT — see LICENSE for details.

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.95 0 3/2/2026
3.0.0-alpha.94 0 3/2/2026
3.0.0-alpha.93 27 3/1/2026
3.0.0-alpha.92 37 2/28/2026
3.0.0-alpha.83 30 2/27/2026