using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Netmash.Extensions.Swagger; using Netmash.Extensions.Swagger.Constants; using Netmash.Infrastructure.DatabaseMigration; using Netmash.Infrastructure.DatabaseMigration.Constants; using Netmash.Test.Api.Extensions; namespace Netmash.Test.Api { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add basic authentication services.AddIdentityAuthentication(Configuration.GetSection("IdentityServer")["BaseAddress"]); services.AddControllers(); services.AddSwagger("Netmash.Test.Api", AuthorizationType.InhouseIdentity); services.AddMigration(DatabaseType.SQLite, MetadataLocation.Database); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Netmash.Test.Api v1")); } app.ConfigureSwagger("Netmash.Test.Api v1"); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseMigration(); } } }