49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using Core.Blueprint.External;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace Core.Thalos.External.GatewayConfigurations
|
|
{
|
|
public class GatewaySettingsConfigurations
|
|
{
|
|
private static GatewayConfiguration GatewayConfigurations { get; set; } = new GatewayConfiguration();
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public GatewaySettingsConfigurations(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
SetDashboardServiceAPIEndpoint();
|
|
}
|
|
public static ThalosServiceAPI GetThalosServiceAPIEndpoint()
|
|
{
|
|
return GatewayConfigurations.ThalosService;
|
|
}
|
|
private GatewayConfiguration SetDashboardServiceAPIEndpoint()
|
|
{
|
|
IConfigurationSection source;
|
|
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
|
|
|
|
if (environment == "Local")
|
|
source = _configuration.GetSection("LocalGateways");
|
|
else
|
|
source = _configuration.GetSection("Gateways");
|
|
|
|
var endpoint = source["ThalosService"] ?? string.Empty;
|
|
|
|
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Thalos Service endpoint is empty or null");
|
|
|
|
GatewayConfigurations.ThalosService = new ThalosServiceAPI()
|
|
{
|
|
Endpoint = new BaseEndpoint()
|
|
{
|
|
Uri = new Uri(endpoint),
|
|
Url = endpoint,
|
|
Token = string.Empty,
|
|
APIName = "Thalos Service"
|
|
}
|
|
};
|
|
|
|
return GatewayConfigurations;
|
|
}
|
|
}
|
|
}
|