Convex.Shared.Http
1.0.0
dotnet add package Convex.Shared.Http --version 1.0.0
NuGet\Install-Package Convex.Shared.Http -Version 1.0.0
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="Convex.Shared.Http" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Convex.Shared.Http" Version="1.0.0" />
<PackageReference Include="Convex.Shared.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 Convex.Shared.Http --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Convex.Shared.Http, 1.0.0"
#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 Convex.Shared.Http@1.0.0
#: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=Convex.Shared.Http&version=1.0.0
#tool nuget:?package=Convex.Shared.Http&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Convex.Shared.Http
Professional HTTP client library for Convex microservices.
Features
- Clean API: Simple and intuitive interface
- JSON Serialization: Automatic JSON serialization/deserialization
- Authentication: API Key and Bearer Token support
- Logging: Built-in request/response logging
- Configuration: Flexible configuration options
- Dependency Injection: Easy integration with .NET DI container
Installation
<PackageReference Include="Convex.Shared.Http" Version="1.0.0" />
Quick Start
1. Register the Service
// In Program.cs
services.AddConvexHttpClient(options =>
{
options.BaseAddress = new Uri("https://api.example.com");
options.ApiKey = "your-api-key";
options.Timeout = TimeSpan.FromSeconds(30);
});
2. Use in Your Service
public class UserService
{
private readonly IConvexHttpClient _httpClient;
public UserService(IConvexHttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<User> GetUserAsync(int userId)
{
return await _httpClient.GetAsync<User>($"/users/{userId}");
}
public async Task<User> CreateUserAsync(CreateUserRequest request)
{
return await _httpClient.PostAsync<CreateUserRequest, User>("/users", request);
}
}
Configuration
Programmatic Configuration
services.AddConvexHttpClient(options =>
{
options.BaseAddress = new Uri("https://api.example.com");
options.Timeout = TimeSpan.FromSeconds(30);
options.ApiKey = "your-api-key";
options.BearerToken = "your-bearer-token";
options.EnableLogging = true;
options.DefaultHeaders.Add("X-Custom-Header", "value");
});
Configuration from appsettings.json
{
"ConvexHttpClient": {
"BaseAddress": "https://api.example.com",
"Timeout": "00:00:30",
"ApiKey": "your-api-key",
"BearerToken": "your-bearer-token",
"EnableLogging": true,
"DefaultHeaders": {
"X-Custom-Header": "value"
}
}
}
services.AddConvexHttpClient(configuration);
Service-to-Service Communication
Simple Setup
services.AddConvexHttpClient(
baseAddress: "https://user-service.example.com",
apiKey: "user-service-key",
timeout: TimeSpan.FromSeconds(15));
Multiple Services
// User Service
services.AddConvexServiceClient(
serviceName: "UserService",
baseAddress: "https://user-service.example.com",
apiKey: "user-service-key");
// Order Service
services.AddConvexServiceClient(
serviceName: "OrderService",
baseAddress: "https://order-service.example.com",
apiKey: "order-service-key");
Error Handling
The client automatically handles common HTTP errors:
try
{
var user = await _httpClient.GetAsync<User>("/users/123");
return user;
}
catch (HttpRequestException ex)
{
// Handle HTTP errors
_logger.LogError(ex, "HTTP request failed");
throw;
}
catch (TaskCanceledException ex)
{
// Handle timeout
_logger.LogError(ex, "Request timed out");
throw;
}
Logging
Enable logging to see request details:
services.AddConvexHttpClient(options =>
{
options.EnableLogging = true;
});
Best Practices
- Use Dependency Injection: Always inject
IConvexHttpClientin your services - Configure Timeouts: Set appropriate timeouts based on your service requirements
- Handle Errors: Implement proper error handling in your services
- Use Logging: Enable logging in development, disable in production for performance
- Configure Authentication: Use API keys or Bearer tokens for service authentication
License
This project is licensed under the MIT License.
| 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
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
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 |
|---|---|---|
| 1.0.0 | 190 | 10/17/2025 |
Initial release of Convex.Shared.Http