More changes to go to .net core 3.x from 2.x

This commit is contained in:
2019-10-16 19:36:05 +00:00
parent d4f51c305d
commit 1ff256029f

View File

@@ -333,33 +333,6 @@ namespace AyaNova
ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedFor | Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedProto
});
#region SWAGGER
_log.LogDebug("BOOT: pipeline - api explorer");
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
// build a swagger endpoint for each discovered API version
foreach (var description in provider.ApiVersionDescriptions)
{
c.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
}
//clean up the swagger explorer UI page and remove the branding
//via our own css
//NOTE: this broke when updated to v2.x of swagger and it can be fixed according to docs:
//https://github.com/domaindrivendev/Swashbuckle.AspNetCore#inject-custom-css
// c.InjectStylesheet("/api/sw.css");
c.DefaultModelsExpandDepth(-1);
c.DocumentTitle = "AyaNova API explorer";
c.RoutePrefix = "api-docs";
});
#endregion swagger
#region STATIC FILES
_log.LogDebug("BOOT: pipeline - static files");
app.UseDefaultFiles();
@@ -379,6 +352,13 @@ namespace AyaNova
// });
#endregion
_log.LogDebug("BOOT: pipeline - ROUTING");
app.UseRouting();//this wasn't here for 2.2 but added for 3.0, needs to come before the stuff after
_log.LogDebug("BOOT: pipeline - CORS");
app.UseCors("CorsPolicy");
#region AUTH / ROLES
_log.LogDebug("BOOT: pipeline - authentication");
//Use authentication middleware
@@ -415,12 +395,47 @@ namespace AyaNova
#endregion
_log.LogDebug("BOOT: pipeline - CORS");
app.UseCors("CorsPolicy");
//USE MVC
_log.LogDebug("BOOT: pipeline - MVC");
app.UseMvc();
#region SWAGGER
_log.LogDebug("BOOT: pipeline - api explorer");
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
// build a swagger endpoint for each discovered API version
foreach (var description in provider.ApiVersionDescriptions)
{
c.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
}
//clean up the swagger explorer UI page and remove the branding
//via our own css
//NOTE: this broke when updated to v2.x of swagger and it can be fixed according to docs:
//https://github.com/domaindrivendev/Swashbuckle.AspNetCore#inject-custom-css
// c.InjectStylesheet("/api/sw.css");
c.DefaultModelsExpandDepth(-1);
c.DocumentTitle = "AyaNova API explorer";
c.RoutePrefix = "api-docs";
});
#endregion swagger
//According to https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio#migrate-startupconfigure
//replace use mvc with use endpoints
// //USE MVC
// _log.LogDebug("BOOT: pipeline - MVC");
// app.UseMvc();
_log.LogDebug("BOOT: pipeline - ENDPOINTS");
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
});
// ******************************************************************
// ******************** TESTING WIPE DB *****************************
@@ -465,7 +480,7 @@ namespace AyaNova
if (TESTING_REFRESH_DB)
{
AyaNova.Core.License.Fetch(apiServerState, dbContext, _log);
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.HugeForLoadTest, -7);//#############################################################################################
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet, -7);//#############################################################################################
}
//TESTING
#endif