Browse Source

fix routing

features/migration-dotnet3
Erik Pique 5 years ago
parent
commit
8b0ec9038f
5 changed files with 18 additions and 30 deletions
  1. +2
    -11
      src/Services/Basket/Basket.API/Startup.cs
  2. +7
    -7
      src/Services/Catalog/Catalog.API/Startup.cs
  3. +5
    -1
      src/Services/Location/Locations.API/Startup.cs
  4. +3
    -10
      src/Services/Marketing/Marketing.API/Startup.cs
  5. +1
    -1
      src/_build/dependencies.props

+ 2
- 11
src/Services/Basket/Basket.API/Startup.cs View File

@ -49,17 +49,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
{
RegisterAppInsights(services);
// Add framework services.
//services.AddMvc(options =>
// {
// options.Filters.Add(typeof(HttpGlobalExceptionFilter));
// options.Filters.Add(typeof(ValidateModelStateFilter));
// })
// .AddNewtonsoftJson()
// .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
// .AddControllersAsServices();
services.AddControllers(options =>
{
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
@ -204,10 +193,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
ConfigureAuth(app);
app.UseAuthorization();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapControllers();
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
{
Predicate = _ => true,


+ 7
- 7
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -55,8 +55,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
.AddSwagger()
.AddCustomHealthCheck(Configuration);
services.AddControllers();
var container = new ContainerBuilder();
container.Populate(services);
@ -139,11 +137,13 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
public static IServiceCollection AddCustomMVC(this IServiceCollection services, IConfiguration configuration)
{
services.AddMvc(options =>
{
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddControllersAsServices();
{
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddControllersAsServices();
services.AddControllers();
services.AddCors(options =>
{


+ 5
- 1
src/Services/Location/Locations.API/Startup.cs View File

@ -51,7 +51,11 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddControllersAsServices();
services.AddControllers();
services.AddControllers(options =>
{
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
}).AddNewtonsoftJson();
ConfigureAuthService(services);


+ 3
- 10
src/Services/Marketing/Marketing.API/Startup.cs View File

@ -23,7 +23,6 @@
using Marketing.API.IntegrationEvents.Handlers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares;
using Microsoft.Extensions.Diagnostics.HealthChecks;
@ -50,15 +49,7 @@
RegisterAppInsights(services);
// Add framework services.
services
.AddCustomHealthCheck(Configuration)
.AddMvc(options =>
{
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
services.AddCustomHealthCheck(Configuration);
services.AddControllers();
services.Configure<MarketingSettings>(Configuration);
@ -198,10 +189,12 @@
ConfigureAuth(app);
app.UseAuthorization();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapControllers();
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
{
Predicate = _ => true,


+ 1
- 1
src/_build/dependencies.props View File

@ -72,7 +72,7 @@
<Microsoft_EntityFrameworkCore_SqlServer>3.0.0-preview7.19362.6</Microsoft_EntityFrameworkCore_SqlServer>
<Microsoft_EntityFrameworkCore_Design>3.0.0-preview7.19362.6</Microsoft_EntityFrameworkCore_Design>
<Microsoft_Extensions_Identity_Stores>3.0.0-preview7.19365.7</Microsoft_Extensions_Identity_Stores>
<Microsoft_Extensions_Configuration_AzureKeyVault>2.2.0</Microsoft_Extensions_Configuration_AzureKeyVault>
<Microsoft_Extensions_Configuration_AzureKeyVault>3.0.0-preview7.19362.4</Microsoft_Extensions_Configuration_AzureKeyVault>
<Microsoft_Extensions_DependencyInjection_Abstractions>2.2.0</Microsoft_Extensions_DependencyInjection_Abstractions>
<Microsoft_Extensions_Diagnostics_HealthChecks>2.2.0</Microsoft_Extensions_Diagnostics_HealthChecks>
<Microsoft_Extensions_Http>2.2.0</Microsoft_Extensions_Http>


Loading…
Cancel
Save