MonadicSharp.Http
1.0.0
dotnet add package MonadicSharp.Http --version 1.0.0
NuGet\Install-Package MonadicSharp.Http -Version 1.0.0
<PackageReference Include="MonadicSharp.Http" Version="1.0.0" />
<PackageVersion Include="MonadicSharp.Http" Version="1.0.0" />
<PackageReference Include="MonadicSharp.Http" />
paket add MonadicSharp.Http --version 1.0.0
#r "nuget: MonadicSharp.Http, 1.0.0"
#:package MonadicSharp.Http@1.0.0
#addin nuget:?package=MonadicSharp.Http&version=1.0.0
#tool nuget:?package=MonadicSharp.Http&version=1.0.0
MonadicSharp.Http
Result-aware HTTP client for .NET 8 — HTTP errors, timeouts, and deserialization failures are typed
Result<T>values, never unhandled exceptions.
Overview
MonadicSharp.Http replaces the fragile try/catch pattern around HttpClient with Railway-Oriented error handling:
IHttpResultClient— typed interface for GET, POST, PUT, PATCH, DELETEHttpResultClient— default implementation backed byHttpClientRetryPolicy— typed retry with exponential backoff, composable withCircuitBreakerHttpResultResponse<T>— wraps result + status code + response headersHttpError— typed error factory for every HTTP failure scenario
Installation
dotnet add package MonadicSharp.Http
Basic Usage
// GET
Result<WeatherForecast> forecast =
await httpClient.GetAsync<WeatherForecast>("/api/weather");
// POST
Result<OrderResponse> order =
await httpClient.PostAsync<OrderRequest, OrderResponse>("/api/orders", orderRequest);
// Railway chain
var result = await httpClient
.GetAsync<UserProfile>($"/api/users/{userId}")
.BindAsync(profile => enrichmentAgent.ExecuteAsync(profile, context));
HttpResultResponse — Access Status & Headers
HttpResultResponse<Page> response =
await httpClient.SendAsync<Page>(new HttpRequestMessage(HttpMethod.Get, "/api/page"));
Console.WriteLine(response.StatusCode); // HttpStatusCode.OK
Console.WriteLine(response.Result.IsSuccess);
if (response.Headers.TryGetValue("X-Rate-Limit-Remaining", out var remaining))
Console.WriteLine(remaining);
RetryPolicy
var retry = new RetryPolicy(
maxAttempts: 3,
initialDelay: TimeSpan.FromMilliseconds(200),
backoffMultiplier: 2.0,
retryOn: error => error.Code is "HTTP_429" or "HTTP_503");
var result = await retry.ExecuteAsync(
ct => httpClient.GetAsync<Data>("/api/data", ct));
// On exhaustion: HttpError.RetryExhausted (contains lastError + attempt count)
Integration with CircuitBreaker
var breaker = new CircuitBreaker("ExternalApi", failureThreshold: 5);
var result = await retry.ExecuteAsync(
ct => breaker.ExecuteAsync(
innerCt => httpClient.GetAsync<Data>("/api/data", innerCt), ct));
Error Codes
| Code | HTTP Trigger |
|---|---|
HTTP_NETWORK_FAILURE |
Network unreachable / DNS failure |
HTTP_TIMEOUT |
HttpClient.Timeout exceeded |
HTTP_CANCELLED |
CancellationToken triggered |
HTTP_BAD_REQUEST |
400 |
HTTP_UNAUTHORIZED |
401 |
HTTP_FORBIDDEN |
403 |
HTTP_NOT_FOUND |
404 |
HTTP_CONFLICT |
409 |
HTTP_UNPROCESSABLE_ENTITY |
422 |
HTTP_RATE_LIMITED |
429 |
HTTP_SERVER_ERROR |
5xx |
HTTP_DESERIALIZATION_FAILED |
JSON parse error on success response |
HTTP_RETRY_EXHAUSTED |
All retry attempts consumed |
DI Registration
// Registers IHttpResultClient + named HttpClient
services.AddMonadicSharpHttp("MyClient", client =>
{
client.BaseAddress = new Uri("https://api.example.com");
client.Timeout = TimeSpan.FromSeconds(30);
});
License
MIT — part of MonadicSharp.Framework.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- MonadicSharp (>= 1.4.0)
- MonadicSharp.Agents (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MonadicSharp.Http:
| Package | Downloads |
|---|---|
|
MonadicSharp.Framework
Meta-package for the MonadicSharp Framework — install this single package to get Agents, Caching, Http, Persistence, Security, and Telemetry in one shot. For à-la-carte usage, reference individual MonadicSharp.* packages instead. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 45 | 3/3/2026 |