Tolitech.Results.Http
1.0.0-preview.4
This is a prerelease version of Tolitech.Results.Http.
dotnet add package Tolitech.Results.Http --version 1.0.0-preview.4
NuGet\Install-Package Tolitech.Results.Http -Version 1.0.0-preview.4
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="Tolitech.Results.Http" Version="1.0.0-preview.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Results.Http" Version="1.0.0-preview.4" />
<PackageReference Include="Tolitech.Results.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 Tolitech.Results.Http --version 1.0.0-preview.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tolitech.Results.Http, 1.0.0-preview.4"
#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 Tolitech.Results.Http@1.0.0-preview.4
#: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=Tolitech.Results.Http&version=1.0.0-preview.4&prerelease
#tool nuget:?package=Tolitech.Results.Http&version=1.0.0-preview.4&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Tolitech.Results.Http
Tolitech.Results.Http provides extension methods to map HTTP responses to Result objects, making error handling and REST API integration seamless.
Features
- Asynchronous reading of problem details from an
HttpResponseMessage
into aResult
object. - Automatic mapping of HTTP status, title, detail, and error messages.
- Transparent integration with the Results pattern.
Basic Usage Example
using Tolitech.Results.Http;
Result<MyResponse> result = new();
var response = await httpClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadFromJsonAsync<MyResponse>();
return result.OK(data!);
}
await result.ReadProblemDetailsAsync(response);
return result;
Main Method
ReadProblemDetailsAsync
Task ReadProblemDetailsAsync(HttpResponseMessage response)
- Reads the HTTP response content and fills the Result object with title, detail, status code, and error messages.
Complete Integration Example
public async Task<Result<CreateOrderResponse>> CreateOrder(CreateOrderRequest request)
{
Result<CreateOrderResponse> result = new();
var response = await httpClient.PostAsJsonAsync("/orders", request);
if (response.IsSuccessStatusCode)
{
var resp = await response.Content.ReadFromJsonAsync<CreateOrderResponse>();
return result.OK(resp!);
}
await result.ReadProblemDetailsAsync(response);
return result;
}
Advanced Tips
- Use together with Tolitech.Results to standardize error handling in APIs.
- Allows customization of the details read from HTTP into the Result.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net9.0
- Tolitech.Results (>= 1.0.0-preview.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Tolitech.Results.Http:
Package | Downloads |
---|---|
Tolitech.HttpClients
Generic HTTP client implementation for .NET, based on Tolitech.HttpClients.Abstractions, with full support for JSON and custom headers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-preview.4 | 315 | 7/25/2025 |
1.0.0-preview.3 | 114 | 7/17/2025 |
1.0.0-preview.2 | 120 | 7/1/2025 |
1.0.0-preview.1 | 145 | 12/6/2024 |