Trellis.Http
3.0.0-alpha.99
This is a prerelease version of Trellis.Http.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Trellis.Http --version 3.0.0-alpha.99
NuGet\Install-Package Trellis.Http -Version 3.0.0-alpha.99
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.99" />
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.99" />
<PackageReference Include="Trellis.Http" />
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.99
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Trellis.Http, 3.0.0-alpha.99"
#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.99
#: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.99&prerelease
#tool nuget:?package=Trellis.Http&version=3.0.0-alpha.99&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
HTTP Client Extensions
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)
Related Packages
- Trellis.Results — Core
Result<T>andMaybe<T>types - Trellis.Asp — ASP.NET Core integration (Result → HTTP responses)
License
MIT — see LICENSE for details.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Trellis.Results (>= 3.0.0-alpha.99)
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.397 | 26 | 6/18/2026 |
| 3.0.0-alpha.396 | 30 | 6/18/2026 |
| 3.0.0-alpha.394 | 42 | 6/18/2026 |
| 3.0.0-alpha.385 | 45 | 6/15/2026 |
| 3.0.0-alpha.382 | 44 | 6/12/2026 |
| 3.0.0-alpha.372 | 55 | 6/10/2026 |
| 3.0.0-alpha.360 | 61 | 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 | 48 | 6/3/2026 |
| 3.0.0-alpha.304 | 52 | 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 | 58 | 3/26/2026 |
| 3.0.0-alpha.127 | 63 | 3/23/2026 |
| 3.0.0-alpha.123 | 66 | 3/19/2026 |
| 3.0.0-alpha.118 | 74 | 3/14/2026 |
| 3.0.0-alpha.99 | 60 | 3/4/2026 |
Loading failed