in web.common project extracted classes copy-pasted in all api projects.
This commit is contained in:
parent
0fe33b7f3d
commit
a399c78c34
@ -96,6 +96,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Marketing", "Marketing", "{
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.API", "src\Services\Marketing\Marketing.API\Marketing.API.csproj", "{DF395F85-B010-465D-857A-7EBCC512C0C2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Marketing.API", "src\Services\Marketing\Marketing.API\Marketing.API.csproj", "{DF395F85-B010-465D-857A-7EBCC512C0C2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web.Common", "src\BuildingBlocks\Web.Common\Web.Common.csproj", "{003782EA-73EC-4330-ABAE-79E050A6F91E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
|
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
|
||||||
@ -1262,6 +1264,54 @@ Global
|
|||||||
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x64.Build.0 = Release|Any CPU
|
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.ActiveCfg = Release|Any CPU
|
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.Build.0 = Release|Any CPU
|
{DF395F85-B010-465D-857A-7EBCC512C0C2}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|ARM.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|ARM.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|x64.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.AppStore|x86.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|iPhone.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|iPhone.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -1308,5 +1358,6 @@ Global
|
|||||||
{23A33F9B-7672-426D-ACF9-FF8436ADC81A} = {88B22DBB-AA8F-4290-A454-2C109352C345}
|
{23A33F9B-7672-426D-ACF9-FF8436ADC81A} = {88B22DBB-AA8F-4290-A454-2C109352C345}
|
||||||
{A5260DE0-1FDD-467E-9CC1-A028AB081CEE} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
|
{A5260DE0-1FDD-467E-9CC1-A028AB081CEE} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
|
||||||
{DF395F85-B010-465D-857A-7EBCC512C0C2} = {A5260DE0-1FDD-467E-9CC1-A028AB081CEE}
|
{DF395F85-B010-465D-857A-7EBCC512C0C2} = {A5260DE0-1FDD-467E-9CC1-A028AB081CEE}
|
||||||
|
{003782EA-73EC-4330-ABAE-79E050A6F91E} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Basket.API.Infrastructure.ActionResults
|
namespace Microsoft.eShopOnContainers.Infrastructure.ActionResults
|
||||||
{
|
{
|
||||||
public class InternalServerErrorObjectResult : ObjectResult
|
public class InternalServerErrorObjectResult : ObjectResult
|
||||||
{
|
{
|
@ -1,19 +1,18 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters
|
namespace Microsoft.eShopOnContainers.Infrastructure.Filters
|
||||||
{
|
{
|
||||||
using AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using global::Ordering.Domain.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using Microsoft.eShopOnContainers.Infrastructure.ActionResults;
|
||||||
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
public class HttpGlobalExceptionFilter<T> : IExceptionFilter
|
||||||
{
|
{
|
||||||
private readonly IHostingEnvironment env;
|
private readonly IHostingEnvironment env;
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
private readonly ILogger<HttpGlobalExceptionFilter<T>> logger;
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter<T>> logger)
|
||||||
{
|
{
|
||||||
this.env = env;
|
this.env = env;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
@ -25,7 +24,7 @@
|
|||||||
context.Exception,
|
context.Exception,
|
||||||
context.Exception.Message);
|
context.Exception.Message);
|
||||||
|
|
||||||
if (context.Exception.GetType() == typeof(OrderingDomainException))
|
if (context.Exception.GetType() == typeof(T))
|
||||||
{
|
{
|
||||||
var json = new JsonErrorResponse
|
var json = new JsonErrorResponse
|
||||||
{
|
{
|
13
src/BuildingBlocks/Web.Common/Web.Common.csproj
Normal file
13
src/BuildingBlocks/Web.Common/Web.Common.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -41,6 +41,7 @@
|
|||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\Web.Common\Web.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
using Basket.API.Infrastructure.ActionResults;
|
|
||||||
using Basket.API.Infrastructure.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace Basket.API.Infrastructure.Filters
|
|
||||||
{
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
|
||||||
{
|
|
||||||
private readonly IHostingEnvironment env;
|
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
|
||||||
{
|
|
||||||
this.env = env;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnException(ExceptionContext context)
|
|
||||||
{
|
|
||||||
logger.LogError(new EventId(context.Exception.HResult),
|
|
||||||
context.Exception,
|
|
||||||
context.Exception.Message);
|
|
||||||
|
|
||||||
if (context.Exception.GetType() == typeof(BasketDomainException))
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { context.Exception.Message }
|
|
||||||
};
|
|
||||||
|
|
||||||
context.Result = new BadRequestObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { "An error occurred. Try it again." }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
json.DeveloperMessage = context.Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Result = new InternalServerErrorObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
}
|
|
||||||
context.ExceptionHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class JsonErrorResponse
|
|
||||||
{
|
|
||||||
public string[] Messages { get; set; }
|
|
||||||
|
|
||||||
public object DeveloperMessage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using Basket.API.Infrastructure.Filters;
|
using Basket.API.Infrastructure.Exceptions;
|
||||||
using Basket.API.IntegrationEvents.EventHandling;
|
using Basket.API.IntegrationEvents.EventHandling;
|
||||||
using Basket.API.IntegrationEvents.Events;
|
using Basket.API.IntegrationEvents.Events;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server;
|
using Microsoft.eShopOnContainers.Infrastructure.Filters;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling;
|
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events;
|
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
||||||
@ -54,7 +54,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter<BasketDomainException>));
|
||||||
}).AddControllersAsServices();
|
}).AddControllersAsServices();
|
||||||
|
|
||||||
services.Configure<BasketSettings>(Configuration);
|
services.Configure<BasketSettings>(Configuration);
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\Web.Common\Web.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.ActionResults
|
|
||||||
{
|
|
||||||
public class InternalServerErrorObjectResult : ObjectResult
|
|
||||||
{
|
|
||||||
public InternalServerErrorObjectResult(object error)
|
|
||||||
: base(error)
|
|
||||||
{
|
|
||||||
StatusCode = StatusCodes.Status500InternalServerError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using Catalog.API.Infrastructure.ActionResults;
|
|
||||||
using Catalog.API.Infrastructure.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Filters
|
|
||||||
{
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
|
||||||
{
|
|
||||||
private readonly IHostingEnvironment env;
|
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
|
||||||
{
|
|
||||||
this.env = env;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnException(ExceptionContext context)
|
|
||||||
{
|
|
||||||
logger.LogError(new EventId(context.Exception.HResult),
|
|
||||||
context.Exception,
|
|
||||||
context.Exception.Message);
|
|
||||||
|
|
||||||
if (context.Exception.GetType() == typeof(CatalogDomainException))
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { context.Exception.Message }
|
|
||||||
};
|
|
||||||
|
|
||||||
context.Result = new BadRequestObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { "An error ocurr.Try it again." }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
json.DeveloperMeesage = context.Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Result = new InternalServerErrorObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
}
|
|
||||||
context.ExceptionHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class JsonErrorResponse
|
|
||||||
{
|
|
||||||
public string[] Messages { get; set; }
|
|
||||||
|
|
||||||
public object DeveloperMeesage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using global::Catalog.API.Infrastructure.Filters;
|
using global::Catalog.API.Infrastructure.Exceptions;
|
||||||
using global::Catalog.API.IntegrationEvents;
|
using global::Catalog.API.IntegrationEvents;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@ -13,6 +13,7 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||||
|
using Microsoft.eShopOnContainers.Infrastructure.Filters;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
||||||
@ -66,7 +67,7 @@
|
|||||||
|
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter<CatalogDomainException>));
|
||||||
}).AddControllersAsServices();
|
}).AddControllersAsServices();
|
||||||
|
|
||||||
services.AddDbContext<CatalogContext>(options =>
|
services.AddDbContext<CatalogContext>(options =>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults
|
|
||||||
{
|
|
||||||
public class InternalServerErrorObjectResult : ObjectResult
|
|
||||||
{
|
|
||||||
public InternalServerErrorObjectResult(object error)
|
|
||||||
: base(error)
|
|
||||||
{
|
|
||||||
StatusCode = StatusCodes.Status500InternalServerError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters
|
|
||||||
{
|
|
||||||
using AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
|
||||||
{
|
|
||||||
private readonly IHostingEnvironment env;
|
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
|
||||||
{
|
|
||||||
this.env = env;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnException(ExceptionContext context)
|
|
||||||
{
|
|
||||||
logger.LogError(new EventId(context.Exception.HResult),
|
|
||||||
context.Exception,
|
|
||||||
context.Exception.Message);
|
|
||||||
|
|
||||||
if (context.Exception.GetType() == typeof(LocationDomainException))
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { context.Exception.Message }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
|
|
||||||
//It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
|
|
||||||
context.Result = new BadRequestObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { "An error occur.Try it again." }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
json.DeveloperMessage = context.Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
|
|
||||||
// It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
|
|
||||||
context.Result = new InternalServerErrorObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
}
|
|
||||||
context.ExceptionHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class JsonErrorResponse
|
|
||||||
{
|
|
||||||
public string[] Messages { get; set; }
|
|
||||||
|
|
||||||
public object DeveloperMessage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,6 +41,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\Web.Common\Web.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -7,7 +7,6 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure;
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories;
|
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories;
|
||||||
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services;
|
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -16,6 +15,8 @@ using Microsoft.Extensions.Logging;
|
|||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions;
|
||||||
|
using Microsoft.eShopOnContainers.Infrastructure.Filters;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Locations.API
|
namespace Microsoft.eShopOnContainers.Services.Locations.API
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
|||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter<LocationDomainException>));
|
||||||
}).AddControllersAsServices();
|
}).AddControllersAsServices();
|
||||||
|
|
||||||
services.Configure<LocationSettings>(Configuration);
|
services.Configure<LocationSettings>(Configuration);
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults
|
|
||||||
{
|
|
||||||
using AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
public class InternalServerErrorObjectResult : ObjectResult
|
|
||||||
{
|
|
||||||
public InternalServerErrorObjectResult(object error)
|
|
||||||
: base(error)
|
|
||||||
{
|
|
||||||
StatusCode = StatusCodes.Status500InternalServerError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters
|
|
||||||
{
|
|
||||||
using AspNetCore.Mvc;
|
|
||||||
using global::Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
|
||||||
{
|
|
||||||
private readonly IHostingEnvironment env;
|
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
|
||||||
{
|
|
||||||
this.env = env;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnException(ExceptionContext context)
|
|
||||||
{
|
|
||||||
logger.LogError(new EventId(context.Exception.HResult),
|
|
||||||
context.Exception,
|
|
||||||
context.Exception.Message);
|
|
||||||
|
|
||||||
if (context.Exception.GetType() == typeof(MarketingDomainException))
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { context.Exception.Message }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
|
|
||||||
//It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
|
|
||||||
context.Result = new BadRequestObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var json = new JsonErrorResponse
|
|
||||||
{
|
|
||||||
Messages = new[] { "An error occur.Try it again." }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
json.DeveloperMessage = context.Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
|
|
||||||
// It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
|
|
||||||
context.Result = new InternalServerErrorObjectResult(json);
|
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
}
|
|
||||||
context.ExceptionHandled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class JsonErrorResponse
|
|
||||||
{
|
|
||||||
public string[] Messages { get; set; }
|
|
||||||
|
|
||||||
public object DeveloperMessage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -56,6 +56,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\Web.Common\Web.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using BuildingBlocks.EventBus.Abstractions;
|
using BuildingBlocks.EventBus.Abstractions;
|
||||||
@ -23,6 +22,8 @@
|
|||||||
using Polly;
|
using Polly;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions;
|
||||||
|
using Microsoft.eShopOnContainers.Infrastructure.Filters;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@
|
|||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter<MarketingDomainException>));
|
||||||
}).AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
|
}).AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
|
||||||
|
|
||||||
services.Configure<MarketingSettings>(Configuration);
|
services.Configure<MarketingSettings>(Configuration);
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults
|
|
||||||
{
|
|
||||||
using AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
public class InternalServerErrorObjectResult : ObjectResult
|
|
||||||
{
|
|
||||||
public InternalServerErrorObjectResult(object error)
|
|
||||||
: base(error)
|
|
||||||
{
|
|
||||||
StatusCode = StatusCodes.Status500InternalServerError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,6 +25,7 @@
|
|||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\Web.Common\Web.Common.csproj" />
|
||||||
<ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" />
|
<ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" />
|
||||||
<ProjectReference Include="..\Ordering.Infrastructure\Ordering.Infrastructure.csproj" />
|
<ProjectReference Include="..\Ordering.Infrastructure\Ordering.Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -4,13 +4,10 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using global::Ordering.API.Application.IntegrationEvents;
|
using global::Ordering.API.Application.IntegrationEvents;
|
||||||
using global::Ordering.API.Application.IntegrationEvents.EventHandling;
|
|
||||||
using global::Ordering.API.Application.IntegrationEvents.Events;
|
using global::Ordering.API.Application.IntegrationEvents.Events;
|
||||||
using global::Ordering.API.Infrastructure.Middlewares;
|
using global::Ordering.Domain.Exceptions;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Auth;
|
|
||||||
using Infrastructure.AutofacModules;
|
using Infrastructure.AutofacModules;
|
||||||
using Infrastructure.Filters;
|
|
||||||
using Infrastructure.Services;
|
using Infrastructure.Services;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@ -20,6 +17,7 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||||
|
using Microsoft.eShopOnContainers.Infrastructure.Filters;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.HealthChecks;
|
using Microsoft.Extensions.HealthChecks;
|
||||||
@ -59,7 +57,7 @@
|
|||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddMvc(options =>
|
services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter<OrderingDomainException>));
|
||||||
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI
|
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI
|
||||||
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
|
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user