netmash/NDB.Test.Api/Startup.cs

60 lines
1.9 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
2023-01-12 01:01:36 +02:00
using Netmash.Extensions.Swagger;
using Netmash.Extensions.Swagger.Constants;
using Netmash.Infrastructure.DatabaseMigration;
using Netmash.Infrastructure.DatabaseMigration.Constants;
using Netmash.Test.Api.Extensions;
2023-01-12 01:01:36 +02:00
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();
2023-01-12 01:07:04 +02:00
services.AddSwagger("Netmash.Test.Api", AuthorizationType.InhouseIdentity);
2022-01-22 00:48:34 +02:00
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();
2023-01-12 01:07:04 +02:00
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Netmash.Test.Api v1"));
}
2023-01-12 01:07:04 +02:00
app.ConfigureSwagger("Netmash.Test.Api v1");
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
2022-01-22 00:48:34 +02:00
app.UseMigration();
}
}
}