MxIO.ApiClient.WebExtensions.V2
1.1.148.1
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MxIO.ApiClient.WebExtensions.V2 --version 1.1.148.1
NuGet\Install-Package MxIO.ApiClient.WebExtensions.V2 -Version 1.1.148.1
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="MxIO.ApiClient.WebExtensions.V2" Version="1.1.148.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MxIO.ApiClient.WebExtensions.V2" Version="1.1.148.1" />
<PackageReference Include="MxIO.ApiClient.WebExtensions.V2" />
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 MxIO.ApiClient.WebExtensions.V2 --version 1.1.148.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MxIO.ApiClient.WebExtensions.V2, 1.1.148.1"
#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 MxIO.ApiClient.WebExtensions.V2@1.1.148.1
#: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=MxIO.ApiClient.WebExtensions.V2&version=1.1.148.1
#tool nuget:?package=MxIO.ApiClient.WebExtensions.V2&version=1.1.148.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MxIO.ApiClient.WebExtensions.V2
This library provides extension methods for integrating API client responses with ASP.NET Core web applications, simplifying the process of converting API responses to appropriate HTTP responses.
Installation
dotnet add package MxIO.ApiClient.WebExtensions.V2
Features
- Extension methods to convert ApiResponse objects to IActionResult
- Extension methods to convert HttpResponseWrapper objects to IActionResult
- Automatic HTTP status code mapping based on API response status
- Preservation of error details in responses
- Support for proper pagination headers
Usage
Basic Usage in Controllers
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
private readonly IUserApiClient _apiClient;
public UsersController(IUserApiClient apiClient)
{
_apiClient = apiClient;
}
[HttpGet("{id}")]
public async Task<IActionResult> GetUser(string id)
{
// Get data from your API client
var response = await _apiClient.GetUserAsync(id);
// Convert the API response to an appropriate HTTP response
return response.ToHttpResult();
}
[HttpGet]
public async Task<IActionResult> GetUsers([FromQuery] FilterOptions filter)
{
// Get collection from your API client
var response = await _apiClient.GetUsersAsync(filter);
// Convert the API response to an HTTP response with pagination headers
return response.ToHttpResult(HttpContext);
}
}
Working with Different Response Types
// Converting ApiResponse<T> to IActionResult
public async Task<IActionResult> GetResource(string id)
{
ApiResponse<ResourceDto> response = await _apiClient.GetResourceAsync(id);
return response.ToHttpResult();
}
// Converting HttpResponseWrapper<T> to IActionResult
public async Task<IActionResult> GetResource(string id)
{
HttpResponseWrapper<ResourceDto> wrapper = await _apiClient.GetResourceWithWrapperAsync(id);
return wrapper.ToHttpResult();
}
Adding Pagination Headers
When returning collections, you can add pagination headers to the response:
public async Task<IActionResult> GetResources([FromQuery] FilterOptions filter)
{
var response = await _apiClient.GetResourcesAsync(filter);
// Adds pagination headers to the HTTP response
return response.ToHttpResult(HttpContext);
}
Error Handling
The extension methods automatically handle error responses:
public async Task<IActionResult> CreateResource([FromBody] ResourceCreateDto dto)
{
var response = await _apiClient.CreateResourceAsync(dto);
// Will return appropriate status code and error details if creation fails
return response.ToHttpResult();
}
Advanced Usage
Custom Response Formatting
You can customize how responses are formatted:
public async Task<IActionResult> GetCustomFormattedResponse(string id)
{
var response = await _apiClient.GetResourceAsync(id);
return response.ToHttpResult(formatResponse: result =>
{
// Custom response formatting
return new
{
resource = result,
timestamp = DateTime.UtcNow,
version = "1.0"
};
});
}
License
GPL-3.0-only
| 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.AspNetCore.Mvc.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.6)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.6)
- Microsoft.Extensions.Options (>= 9.0.6)
- MxIO.ApiClient.Abstractions.V2 (>= 1.1.148.1)
- 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 |
|---|