60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using NDB.Extensions.Swagger;
|
|
using NDB.Extensions.Swagger.Constants;
|
|
using NDB.Infrastructure.DatabaseMigration;
|
|
using NDB.Infrastructure.DatabaseMigration.Constants;
|
|
using NDB.Test.Api.Extensions;
|
|
|
|
namespace NDB.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("NDB.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", "NDB.Test.Api v1"));
|
|
}
|
|
|
|
app.ConfigureSwagger("NDB.Test.Api v1");
|
|
app.UseRouting();
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
|
|
app.UseMigration();
|
|
}
|
|
}
|
|
}
|