60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using IgniteUI.Blazor.Controls;
|
|
using OI.Metrology.View.Models;
|
|
using Serilog;
|
|
using Serilog.Core;
|
|
|
|
namespace OI.Metrology.ClientHub;
|
|
|
|
internal class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
|
LoggingLevelSwitch levelSwitch = new();
|
|
LoggerConfiguration loggerConfiguration = new();
|
|
// _ = loggerConfiguration.WriteTo.BrowserConsole();
|
|
// _ = loggerConfiguration.MinimumLevel.ControlledBy(levelSwitch);
|
|
// _ = loggerConfiguration.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("n"));
|
|
// _ = loggerConfiguration.WriteTo.BrowserHttp($"{apiUrl}ingest", controlLevelSwitch: levelSwitch);
|
|
Log.Logger = loggerConfiguration.CreateLogger();
|
|
Serilog.ILogger log = Log.ForContext<Program>();
|
|
try
|
|
{
|
|
AppSettings appSettings = View.Models.Binder.AppSettings.Get(builder.Configuration);
|
|
// Add services to the container.
|
|
_ = builder.Services.AddRazorPages();
|
|
_ = builder.Services.AddIgniteUIBlazor(typeof(IgbIconModule));
|
|
_ = builder.Services.AddServerSideBlazor();
|
|
_ = builder.Services.AddHttpContextAccessor();
|
|
|
|
_ = builder.Services.AddSingleton(_ => appSettings);
|
|
_ = builder.Services.AddScoped(serviceProvider => new HttpClient { BaseAddress = new Uri(appSettings.ApiUrl) });
|
|
|
|
WebApplication app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
_ = app.UseExceptionHandler("/Error");
|
|
// 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.UseRouting();
|
|
|
|
_ = app.MapBlazorHub();
|
|
_ = app.MapFallbackToPage("/_Host");
|
|
|
|
app.Run();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Fatal(ex, "An exception occurred while creating the WASM host");
|
|
throw;
|
|
}
|
|
}
|
|
} |