A lightweight .NET library providing HTTP extensions for simplified JSON operations, HTTP client helpers, and API client abstractions with JWT support. Includes extensions for HttpContent, HttpClient, HttpClientFactory, and dependency injection setup. See GitHub for full documentation and examples.
$ dotnet add package SimplyWorks.HttpExtensionsA lightweight .NET library that provides useful extensions for HTTP operations, including JSON serialization/deserialization, HTTP client factory helpers, and API client abstractions.
Install via NuGet Package Manager:
dotnet add package SimplyWorks.HttpExtensions
Or via Package Manager Console:
Install-Package SimplyWorks.HttpExtensions
using SW.HttpExtensions;
// Deserialize JSON response to strongly typed object
var response = await httpClient.GetAsync("api/users");
var users = await response.Content.ReadAsAsync<List<User>>();
using SW.HttpExtensions;
// POST with automatic JSON serialization
var user = new User { Name = "John", Email = "john@example.com" };
var response = await httpClient.PostAsync("api/users", user);
// POST with automatic deserialization
var createdUser = await httpClient.PostAsync<User>("api/users", user);
// GET with automatic deserialization
var users = await httpClient.GetAsync<List<User>>("api/users");
// PUT with automatic JSON serialization
await httpClient.PutAsync("api/users/1", user);
using SW.HttpExtensions;
// Create client with base address and JWT authentication
var client = httpClientFactory.CreateClient(
new Uri("https://api.example.com"),
jwt: "your-jwt-token"
);
using SW.HttpExtensions;
// Add JWT token parameters from configuration
services.AddJwtTokenParameters(options =>
{
// Configure JWT options
});
// Add API client with options
services.AddApiClient<IUserApi, UserApiClient, UserApiMock, UserApiOptions>(options =>
{
options.BaseUrl = "https://api.example.com";
options.Mock = false;
});
This project is licensed under the MIT License - see the LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any bugs or have feature requests, please submit an issue.