Vulttech_HttpClient 1.0.7
See the version list below for details.
dotnet add package Vulttech_HttpClient --version 1.0.7
NuGet\Install-Package Vulttech_HttpClient -Version 1.0.7
<PackageReference Include="Vulttech_HttpClient" Version="1.0.7" />
<PackageVersion Include="Vulttech_HttpClient" Version="1.0.7" />
<PackageReference Include="Vulttech_HttpClient" />
paket add Vulttech_HttpClient --version 1.0.7
#r "nuget: Vulttech_HttpClient, 1.0.7"
#:package Vulttech_HttpClient@1.0.7
#addin nuget:?package=Vulttech_HttpClient&version=1.0.7
#tool nuget:?package=Vulttech_HttpClient&version=1.0.7
HttpClient Customizado para los llamados a los endpoint
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. 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. |
-
net8.0
- AspNetCore.Authentication.Basic (>= 9.0.0)
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.6)
- Microsoft.Extensions.Http (>= 9.0.6)
- Microsoft.Graph (>= 5.81.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.
🌐 Vulttech_HttpClient
Cliente HTTP reutilizable para microservicios basado en HttpClientFactory. Facilita llamados HTTP con soporte para autenticación, serialización automática, logging y configuración por appsettings.
📦 Instalación
bash
dotnet add package Vulttech.HttpClient --version 1.0.7
🚀 Características
Soporte para GET, POST, PUT, PATCH, HEAD
Autenticación por Bearer, Basic, o ninguna (None)
Lectura automática de endpoints desde appsettings.json
Compatible con IHttpClientFactory
Factory personalizado HttpClientVulttechFactory
Inyección de dependencias lista para usar
Manejo de errores centralizado
Logging integrado
Version 1.0.7 correccion de errores url
🔧 Configuración
1. En appsettings.json
json ejemplo:
"ServiceEndpoints": {
"Usuarios": "https://api.midominio.com/usuarios",
"Turnos": "https://api.midominio.com/turnos",
"Authentication": {
"User": "UsuarioBasic",
"Password": "123456",
"ApiUser": "UsuarioApi",
"ApiKey": "123456789"
}
},
"JwtSeccion": {
"Key": "clave-qweqwewqeqweqweqweqwe",
"Issuer": "Issuer",
"Audience": "Audience",
"ExpiresInMinutes": 1000
},
La key Authentication puede estar dentro de los endpoint o fuera de el independientemente
2. En Program.cs
builder.Services.AddVulttechHttpClients(builder.Configuration, "ServiceEndpoints", "Authentication", "JwtSeccion");
Esto agrega automáticamente un HttpClient nombrado para cada microservicio.
🧑💻 Cómo usar
1. Inyectar la Factory
Csharp
public class UsuarioClient
{
private readonly HttpClientVulttech _httpClienteVult;
public UsuarioClient(IHttpClientVulttechFactory factory)
{
_httpClienteVult = factory.CreateClientVult("Usuarios")
}
🔐 Autenticación
El método GetAsync, PostAsync, etc., aceptan un parámetro AuthenticationType:
csharp
public enum AuthenticationType
{
None,
Bearer,
Basic,
ApiKey
}
Ejemplo de POST con autenticación Bearer:
csharp
var usuario = new Usuario { Nombre = "Juan" };
Usuario usuarioResponse = await httpClienteVult.PostAsync<Usuario>("api/usuarios", usuario, AuthenticationType.Bearer);
🔍 Logging
Incluye logs de entrada/salida si inyectás ILogger<IHttpClientVulttech>.
📤 Métodos disponibles
csharp
Task<T?> GetAsync<T>(string requestUri, AuthenticationType auth = None);
Task<TResponse?> PostAsync<TResponse>(string requestUri, object body, AuthenticationType auth = None);
Task<TResponse?> PutAsync<TResponse>(string requestUri, object body, AuthenticationType auth = None);
Task<TResponse?> PatchAsync<TResponse>(string requestUri, object body, AuthenticationType auth = None);
Task<HttpResponseMessage> HeadAsync(string requestUri, AuthenticationType auth = None);
🤝 Requisitos
.NET 6 o superior
Configuración de ServiceEndpoints en tu aplicación
Token disponible en HttpContext si usás Bearer