Implement US-10 on-demand health insights

This commit is contained in:
Steffen committed 2026-10-02 09:57:06 +02:00
1 parent 4cb6798ec9
commit a5b269cfc3
25 files changed
+482 -4

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
using InsightsService.Application;
using InsightsService.Clients;
using InsightsService.Domain;
namespace InsightsService;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddProblemDetails();
builder.Services.AddScoped<InsightsApplicationService>();
builder.Services.AddSingleton<InsightCalculator>();
builder.Services.AddHttpClient<ObservationServiceClient, HttpObservationServiceClient>((services, client) =>
client.BaseAddress = GetGatewayUri(services.GetRequiredService<IConfiguration>()))
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
var app = builder.Build();
_ = GetGatewayUri(app.Configuration);
app.UseExceptionHandler();
app.MapControllers();
app.Run();
}
private static Uri GetGatewayUri(IConfiguration configuration)
{
var endpoint = configuration["Services:ApiGateway:BaseUrl"];
if (!Uri.TryCreate(endpoint, UriKind.Absolute, out var uri) ||
(uri.Scheme != "http" && uri.Scheme != "https") || uri.AbsolutePath != "/" ||
!string.IsNullOrEmpty(uri.Query) || !string.IsNullOrEmpty(uri.Fragment) || !string.IsNullOrEmpty(uri.UserInfo))
throw new InvalidOperationException("Services:ApiGateway:BaseUrl must be an HTTP(S) origin URL.");
return uri;
}
}