Replaced direct configuration access for the API base URL with retrieval from an AppSettings object. Updated HttpClient configuration to use appSettings.ApiBaseUrl, improving consistency and maintainability. Existing AppSettings DI registration is retained.
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using DbFirst.BlazorWebApp;
|
|
using DbFirst.BlazorWebApp.Components;
|
|
using DbFirst.BlazorWebApp.Services;
|
|
using DevExpress.Blazor;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
builder.Services.AddDevExpressBlazor(options => options.BootstrapVersion = BootstrapVersion.v5);
|
|
builder.Services.AddScoped<ThemeState>();
|
|
builder.Services.AddScoped<BandLayoutService>();
|
|
|
|
builder.Services.Configure<AppSettings>(builder.Configuration);
|
|
var appSettings = builder.Configuration.Get<AppSettings>() ?? new AppSettings();
|
|
void ConfigureClient(HttpClient client)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(appSettings.ApiBaseUrl))
|
|
client.BaseAddress = new Uri(appSettings.ApiBaseUrl);
|
|
}
|
|
|
|
builder.Services.AddHttpClient<ICatalogApiClient, CatalogApiClient>(ConfigureClient);
|
|
builder.Services.AddHttpClient<IDashboardApiClient, DashboardApiClient>(ConfigureClient);
|
|
builder.Services.AddHttpClient<IMassDataApiClient, MassDataApiClient>(ConfigureClient);
|
|
builder.Services.AddHttpClient<ILayoutApiClient, LayoutApiClient>(ConfigureClient);
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run(); |