Netcore3.0 (#323)
* Updates based on documentation * Getting the build passing * Getting app functioning * A few cleanups to confirm it's working as expected * Fixing functional tests * Updating dockerfile for 3.0 * Functional Tests now run sequentially * Updating to latest version of moq * Adding migration for post 3.0 upgrades * Removing commented out lines * Moving address and catalogitemordered configuration in to classes that own them * Minor cleanups
This commit is contained in:
committed by
Steve Smith
parent
9a21db6979
commit
4442015835
@@ -4,10 +4,7 @@ using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.UI;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Services;
|
||||
@@ -15,14 +12,13 @@ using Microsoft.eShopWeb.Infrastructure.Data;
|
||||
using Microsoft.eShopWeb.Infrastructure.Identity;
|
||||
using Microsoft.eShopWeb.Infrastructure.Logging;
|
||||
using Microsoft.eShopWeb.Infrastructure.Services;
|
||||
using Microsoft.eShopWeb.Web.HealthChecks;
|
||||
using Microsoft.eShopWeb.Web.Interfaces;
|
||||
using Microsoft.eShopWeb.Web.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -87,7 +83,6 @@ namespace Microsoft.eShopWeb.Web
|
||||
CreateIdentityIfNotCreated(services);
|
||||
|
||||
services.AddScoped(typeof(IAsyncRepository<>), typeof(EfRepository<>));
|
||||
|
||||
services.AddScoped<ICatalogViewModelService, CachedCatalogViewModelService>();
|
||||
services.AddScoped<IBasketService, BasketService>();
|
||||
services.AddScoped<IBasketViewModelService, BasketViewModelService>();
|
||||
@@ -96,7 +91,6 @@ namespace Microsoft.eShopWeb.Web
|
||||
services.AddScoped<CatalogViewModelService>();
|
||||
services.Configure<CatalogSettings>(Configuration);
|
||||
services.AddSingleton<IUriComposer>(new UriComposer(Configuration.Get<CatalogSettings>()));
|
||||
|
||||
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
|
||||
services.AddTransient<IEmailSender, EmailSender>();
|
||||
|
||||
@@ -114,25 +108,21 @@ namespace Microsoft.eShopWeb.Web
|
||||
{
|
||||
options.Conventions.Add(new RouteTokenTransformerConvention(
|
||||
new SlugifyParameterTransformer()));
|
||||
|
||||
}
|
||||
)
|
||||
.AddRazorPagesOptions(options =>
|
||||
{
|
||||
options.Conventions.AuthorizePage("/Basket/Checkout");
|
||||
options.AllowAreas = true;
|
||||
})
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||
|
||||
});
|
||||
services.AddControllersWithViews();
|
||||
services.AddRazorPages(options =>
|
||||
{
|
||||
options.Conventions.AuthorizePage("/Basket/Checkout");
|
||||
});
|
||||
|
||||
services.AddControllers();
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
|
||||
});
|
||||
|
||||
services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApi.Models.OpenApiInfo { Title = "My API", Version = "v1"}));
|
||||
|
||||
services.AddHealthChecks()
|
||||
.AddCheck<HomePageHealthCheck>("home_page_health_check")
|
||||
.AddCheck<ApiHealthCheck>("api_health_check");
|
||||
services.AddHealthChecks();
|
||||
|
||||
services.Configure<ServiceConfig>(config =>
|
||||
{
|
||||
@@ -154,7 +144,7 @@ namespace Microsoft.eShopWeb.Web
|
||||
if(existingUserManager == null)
|
||||
{
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>()
|
||||
.AddDefaultUI(UIFramework.Bootstrap4)
|
||||
.AddDefaultUI()
|
||||
.AddEntityFrameworkStores<AppIdentityDbContext>()
|
||||
.AddDefaultTokenProviders();
|
||||
}
|
||||
@@ -183,9 +173,8 @@ namespace Microsoft.eShopWeb.Web
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//app.UseDeveloperExceptionPage();
|
||||
app.UseHealthChecks("/health",
|
||||
new HealthCheckOptions
|
||||
{
|
||||
@@ -220,9 +209,11 @@ namespace Microsoft.eShopWeb.Web
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseCookiePolicy();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseCookiePolicy();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
// Enable middleware to serve generated Swagger as a JSON endpoint.
|
||||
app.UseSwagger();
|
||||
@@ -234,11 +225,12 @@ namespace Microsoft.eShopWeb.Web
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
|
||||
});
|
||||
|
||||
app.UseMvc(routes =>
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller:slugify=Home}/{action:slugify=Index}/{id?}");
|
||||
endpoints.MapControllerRoute("default", "{controller:slugify=Home}/{action:slugify=Index}/{id?}");
|
||||
endpoints.MapRazorPages();
|
||||
endpoints.MapHealthChecks("home_page_health_check");
|
||||
endpoints.MapHealthChecks("api_health_check");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user