Выброс исключения, если в appsettings.json в секции ClientUrl не указан путь до Persistence-сервера
Some checks failed
Unit tests / test (push) Failing after 55s
Some checks failed
Unit tests / test (push) Failing after 55s
This commit is contained in:
parent
6593acbc20
commit
d0cd647849
@ -53,6 +53,7 @@
|
||||
<PackageReference Include="Refit" Version="8.0.0" />
|
||||
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||
using DD.Persistence.Client.Helpers;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Refit;
|
||||
using System.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DD.Persistence.Client;
|
||||
@ -18,11 +20,19 @@ public class RefitClientFactory<T> : IRefitClientFactory<T> where T : IRefitClie
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public RefitClientFactory(IConfiguration configuration)
|
||||
public RefitClientFactory(IConfiguration configuration, ILogger<IRefitClientFactory<T>> logger)
|
||||
{
|
||||
this.client = new HttpClient();
|
||||
|
||||
var baseUrl = configuration.GetSection("ClientUrl").Get<string>()!;
|
||||
var baseUrl = configuration.GetSection("ClientUrl").Get<string>();
|
||||
if (String.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса.");
|
||||
|
||||
logger.LogError(exception.Message);
|
||||
|
||||
throw exception;
|
||||
}
|
||||
client.BaseAddress = new Uri(baseUrl);
|
||||
client.Authorize(configuration);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user