using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; using NDB.Extensions.Swagger; using NDB.Extensions.Swagger.Constants; using NDB.Infrastructure.DatabaseMigration; using NDB.Security.Authentication.Identity; using Newtonsoft.Json; using ProxmoxConnector.Server.Application; using ProxmoxConnector.Server.Domain.Abstractions; using ProxmoxConnector.Server.Services; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace ProxmoxConnector.Server { public class Startup { private readonly IConfiguration _configuration; public Startup(IConfiguration configuration) { _configuration = configuration; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(o => o.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc); // Add basic authentication services.AddIdentityAuthentication(_configuration.GetSection("IdentityServer")["BaseAddress"]); services.AddHttpContextAccessor(); services.AddScoped(); services.AddSwagger("ProxmoxConnector.Server", AuthorizationType.InhouseIdentity); services.AddAutoMapper(typeof(Application.Mappings.MappingProfile).Assembly); var workspace = _configuration.GetValue("Workspace"); services.AddMigration(workspace: workspace); //services.AddDataAccess(); services.AddApplicationServices(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseExceptionHandler("/error"); app.ConfigureSwagger("CDN.Server v1"); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseMigration(); } } }