HTTP client extensions for seamless Result pattern integration with web API responses. Features automatic status code mapping, JSON deserialization, validation problem handling, and comprehensive error conversion for HTTP operations.
$ dotnet add package FlowRight.HttpA production-grade Result pattern implementation for .NET that eliminates exception-based control flow while providing comprehensive validation and HTTP integration capabilities.
Match and imperative Switch methods for elegant control flow| Package | Description | Status |
|---|---|---|
FlowRight.Core | Core Result pattern implementation | 🚀 Ready for v1.0 |
FlowRight.Validation | Fluent validation builder with Result integration | 🚀 Ready for v1.0 |
FlowRight.Http | HTTP response to Result conversion | 🚀 Ready for v1.0 |
Note: All core features are complete and tested. Version 1.0.0 production release is ready.
# Production-ready packages
# Core Result pattern
dotnet add package FlowRight.Core
# Validation support
dotnet add package FlowRight.Validation
# HTTP integration
dotnet add package FlowRight.Http
📦 Latest Version: v1.0.0 - Production ready with stable APIs
using FlowRight.Core.Results;
// Simple success/failure
Result<int> Divide(int numerator, int denominator)
{
if (denominator == 0)
return Result.Failure<int>("Cannot divide by zero");
return Result.Success(numerator / denominator);
}
// Pattern matching
string message = Divide(10, 2).Match(
onSuccess: value => $"Result: {value}",
onFailure: error => $"Error: {error}"
);
// Using Switch for side effects
Divide(10, 0).Switch(
onSuccess: value => Console.WriteLine($"Success: {value}"),
onFailure: error => Console.WriteLine($"Failed: {error}")
);
using FlowRight.Validation.Builders;
public Result<User> CreateUser(CreateUserRequest request)
{
return new ValidationBuilder<User>()
.RuleFor(x => x.Name, request.Name)
.NotEmpty()
.MinimumLength(2)
.MaximumLength(100)
.RuleFor(x => x.Email, request.Email)
.NotEmpty()
.EmailAddress()
.RuleFor(x => x.Age, request.Age)
.GreaterThan(0)
.LessThan(150)
.Build(() => new User(request.Name, request.Email, request.Age));
}
using FlowRight.Http.Extensions;
public async Task<Result<WeatherData>> GetWeatherAsync(string city)
{
HttpResponseMessage response = await _httpClient.GetAsync($"/weather/{city}");
return await response.ToResultFromJsonAsync<WeatherData>();
}
// Automatically handles:
// - 2xx → Success with deserialized data
// - 400 → Validation errors from Problem Details
// - 401/403 → Security failures
// - 404 → Not found
// - 5xx → Server errors
Result<Order> CreateOrder(OrderRequest request)
{
Result<Customer> customerResult = GetCustomer(request.CustomerId);
Result<Product> productResult = GetProduct(request.ProductId);
Result<Address> addressResult = ValidateAddress(request.ShippingAddress);
// Combine multiple results
Result combined = Result.Combine(customerResult, productResult, addressResult);
if (combined.IsFailure)
return Result.Failure<Order>(combined.Error);
// All results are successful, create the order
return Result.Success(new Order(
customerResult.Value,
productResult.Value,
addressResult.Value
));
}
# Clone the repository
git clone https://github.com/georgepharrison/FlowRight.git
cd FlowRight
# Build the solution
dotnet build
# Run tests
dotnet test
# Run benchmarks
dotnet run -c Release --project benchmarks/Benchmarks/Benchmarks.csproj
FlowRight includes comprehensive integration tests covering:
The project maintains comprehensive test coverage with 1,721 passing tests across all packages:
Total: 1,721 tests with 84 skipped conditional tests, achieving comprehensive coverage for production release.
# Run all tests with coverage
dotnet test --collect:"XPlat Code Coverage" --results-directory ./coverage
# Generate coverage report (requires ReportGenerator)
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:coverage/**/coverage.cobertura.xml -targetdir:coverage/report -reporttypes:Html
FlowRight is designed for minimal overhead and zero allocations on the success path. After extensive optimization work, we've achieved significant performance improvements:
| Operation | Time | Allocations | vs Exceptions |
|---|---|---|---|
| Result.Success() | 19.11ns | 0 bytes | ~10x faster |
| Result.Failure() | 5.46ns | <100 bytes | ~100x faster |
| Pattern Match | ~78ns | 0 bytes | No exceptions |
| Validation (10 rules) | ~200ns | <500 bytes | ~50x faster |
Performance Note: Results measured on .NET 9.0 using BenchmarkDotNet. Your results may vary based on hardware and .NET version.
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
flowrightCore Library:
Validation Library:
HTTP Integration:
Production Release (85/85 core tasks complete):
See CHANGELOG.md for version history.
Made with ❤️ by the .NET community