TheNevix.Utils.RequestHandler
1.1.0-beta-240812-3
See the version list below for details.
dotnet add package TheNevix.Utils.RequestHandler --version 1.1.0-beta-240812-3
NuGet\Install-Package TheNevix.Utils.RequestHandler -Version 1.1.0-beta-240812-3
<PackageReference Include="TheNevix.Utils.RequestHandler" Version="1.1.0-beta-240812-3" />
paket add TheNevix.Utils.RequestHandler --version 1.1.0-beta-240812-3
#r "nuget: TheNevix.Utils.RequestHandler, 1.1.0-beta-240812-3"
// Install TheNevix.Utils.RequestHandler as a Cake Addin #addin nuget:?package=TheNevix.Utils.RequestHandler&version=1.1.0-beta-240812-3&prerelease // Install TheNevix.Utils.RequestHandler as a Cake Tool #tool nuget:?package=TheNevix.Utils.RequestHandler&version=1.1.0-beta-240812-3&prerelease
TheNevix.Utils.RequestHandler
A simple and flexible HTTP request handler utility for .NET applications. This library simplifies making API calls by providing an easy-to-use interface for sending HTTP requests with optional headers and handling responses.
Features
- Simplified API for making HTTP requests
- Support for adding custom headers
- Built-in error handling and response validation
- Supports .NET 6.0, 7.0, and 8.0
Installation
You can install the package via NuGet Package Manager, .NET CLI, or by adding it to your project file.
NuGet Package Manager
Install-Package TheNevix.Utils.RequestHandler
Configuration
Enable the RequestHandler in your program.cs file.
builder.Services.AddRequestHandlerServices();
Usage
This is an example of a basic GET request.
public class SomeService
{
private readonly IRequestHandler _requestHandler;
public SomeService(IRequestHandler requestHandler)
{
_requestHandler = requestHandler;
}
public async Task DoSomethingAsync(string url)
{
var response = await _requestHandler.GetAsync(url);
// Process the response
}
}
All methods either return a JSON string as a result of the request or an exception.
Here's an example to pass headers to the GET request.
public class SomeService
{
private readonly IRequestHandler _requestHandler;
public SomeService(IRequestHandler requestHandler)
{
_requestHandler = requestHandler;
}
public async Task DoSomethingAsync(string url)
{
var someHeaders = new Dictionary<string, string>
{
{ "Authorization", "Bearer ey..." }
};
var someRequestOptions = new RequestHandlerOptions(someHeaders);
var response = await _requestHandler.GetAsync(url, someRequestOptions);
// Process the response
}
}
This example applies for a methods, except for PUT, PATCH and POST. These methods also expect a body.
Notes
Since I don't really use the DELETE request I have left it out for now. It will be added in the near future.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
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.1.4 | 0 | 12/2/2024 |
1.1.3 | 0 | 12/2/2024 |
1.1.2 | 0 | 12/2/2024 |
1.1.1 | 18 | 12/2/2024 |
1.1.0 | 132 | 8/14/2024 |
1.1.0-beta-240813 | 113 | 8/13/2024 |
1.1.0-beta-240812-4 | 100 | 8/12/2024 |
1.1.0-beta-240812-3 | 102 | 8/12/2024 |
1.1.0-alpha-240812-2 | 104 | 8/12/2024 |
1.1.0-alpha-240812 | 107 | 8/12/2024 |
1.0.0 | 134 | 8/10/2024 |
Beta version of 1.1.0.