73 lines
2 KiB
C#
73 lines
2 KiB
C#
using Autofac;
|
|
|
|
namespace PlanTempus
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IWebHostEnvironment env)
|
|
{
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(env.ContentRootPath)
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddEnvironmentVariables();
|
|
|
|
ConfigurationRoot = builder.Build();
|
|
}
|
|
|
|
public IConfigurationRoot ConfigurationRoot { get; private set; }
|
|
|
|
public ILifetimeScope AutofacContainer { get; private set; }
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddControllers();
|
|
services.AddOptions();
|
|
services.AddRazorPages();
|
|
//services.AddApplicationInsightsTelemetry(ConfigurationRoot["ApplicationInsights:InstrumentationKey"]);
|
|
services.AddAntiforgery(x => x.HeaderName = "X-ANTI-FORGERY-TOKEN");
|
|
|
|
services.Configure<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions>(options =>
|
|
{
|
|
options.ViewLocationExpanders.Add(new Application.Common.ComponentsViewLocationExpander());
|
|
});
|
|
|
|
}
|
|
public void ConfigureContainer(ContainerBuilder builder)
|
|
{
|
|
builder.RegisterModule(new Core.ModuleRegistry.DbPostgreSqlModule
|
|
{
|
|
ConnectionString = ConfigurationRoot.GetConnectionString("ptdb")
|
|
});
|
|
|
|
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule
|
|
{
|
|
TelemetryConfig = ConfigurationRoot.GetSection("ApplicationInsights").Get<Core.ModuleRegistry.TelemetryConfig>()
|
|
});
|
|
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
|
|
if (env.IsDevelopment())
|
|
app.UseDeveloperExceptionPage();
|
|
else
|
|
{
|
|
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.UseRouting();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
//endpoints.MapHub<MotionHub>("/motionhub");
|
|
endpoints.MapRazorPages();
|
|
endpoints.MapControllers();
|
|
});
|
|
|
|
}
|
|
}
|
|
}
|