|
@@ -1,6 +1,7 @@
|
|
|
using DataSharing.Share.Dtos.Province;
|
|
|
using IdentityModel.Client;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
using System.Net.Http.Headers;
|
|
|
using System.Net.Http.Json;
|
|
|
using System.Text;
|
|
@@ -13,10 +14,12 @@ namespace DataSharing;
|
|
|
public class BaseHttpInvoker : IHttpInvoker, IScopeDependency
|
|
|
{
|
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
|
+ private readonly ILogger<BaseHttpInvoker> _logger;
|
|
|
|
|
|
- public BaseHttpInvoker(IHttpClientFactory httpClientFactory)
|
|
|
+ public BaseHttpInvoker(IHttpClientFactory httpClientFactory, ILogger<BaseHttpInvoker> logger)
|
|
|
{
|
|
|
_httpClientFactory = httpClientFactory;
|
|
|
+ _logger = logger;
|
|
|
}
|
|
|
|
|
|
public async Task<TResponse?> RequestAsync<TRequest, TResponse>(
|
|
@@ -54,7 +57,6 @@ public class BaseHttpInvoker : IHttpInvoker, IScopeDependency
|
|
|
Action<HttpClient>? setHttpClient = null, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
var httpClient = _httpClientFactory.CreateClient();
|
|
|
-
|
|
|
if (setHttpClient != null)
|
|
|
setHttpClient.Invoke(httpClient);
|
|
|
|
|
@@ -79,6 +81,7 @@ public class BaseHttpInvoker : IHttpInvoker, IScopeDependency
|
|
|
{
|
|
|
PropertyNameCaseInsensitive = true
|
|
|
};
|
|
|
+ _logger.LogWarning("请求返回数据:-----------------" + rsp);
|
|
|
return JsonSerializer.Deserialize<TResponse>(rsp, options);
|
|
|
// return System.Text.Json.JsonSerializer.Deserialize<TResponse>(rsp);
|
|
|
}
|