ddd-refactor #2

Merged
mz merged 46 commits from ddd-refactor into main 2025-11-28 11:14:43 +01:00
Showing only changes of commit cfb0cdc2f7 - Show all commits

View File

@@ -12,19 +12,26 @@ public static class ServiceCollectionExtensions
// Ensure BaseAddress ends with / for proper relative URL resolution // Ensure BaseAddress ends with / for proper relative URL resolution
var baseUri = apiBaseUrl.EndsWith('/') ? apiBaseUrl : apiBaseUrl + "/"; var baseUri = apiBaseUrl.EndsWith('/') ? apiBaseUrl : apiBaseUrl + "/";
Console.WriteLine($"🔧 Configuring HttpClient with BaseAddress: {baseUri}");
services.AddTransient<HttpLoggingHandler>(); services.AddTransient<HttpLoggingHandler>();
services.AddHttpClient<AuthService>(client => // Configure named HttpClient with logging handler
services.AddHttpClient("DiunaBI", client =>
{ {
client.BaseAddress = new Uri(baseUri); client.BaseAddress = new Uri(baseUri);
Console.WriteLine($"✅ HttpClient BaseAddress set to: {client.BaseAddress}");
}) })
.AddHttpMessageHandler<HttpLoggingHandler>(); .AddHttpMessageHandler<HttpLoggingHandler>();
services.AddHttpClient<LayerService>(client => // Register a scoped HttpClient factory that services will use
services.AddScoped<HttpClient>(sp =>
{ {
client.BaseAddress = new Uri(baseUri); var factory = sp.GetRequiredService<IHttpClientFactory>();
}) var client = factory.CreateClient("DiunaBI");
.AddHttpMessageHandler<HttpLoggingHandler>(); Console.WriteLine($"🏭 HttpClient created from factory. BaseAddress: {client.BaseAddress}");
return client;
});
// Services // Services
services.AddScoped<AuthService>(); services.AddScoped<AuthService>();