Merge branch 'master'

pull/847/head
Atakan Özceviz 7 years ago
commit bb71887096

@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.AspNetCore.Auditing;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Tracing;
using Volo.Abp.AspNetCore.Uow;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Localization;
@ -40,6 +41,12 @@ namespace Microsoft.AspNetCore.Builder
.UseMiddleware<AbpUnitOfWorkMiddleware>();
}
public static IApplicationBuilder UseCorrelationId(this IApplicationBuilder app)
{
return app
.UseMiddleware<AbpCorrelationIdMiddleware>();
}
public static IApplicationBuilder UseAbpRequestLocalization(this IApplicationBuilder app)
{
IReadOnlyList<LanguageInfo> languages;

@ -0,0 +1,58 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
using Volo.Abp.Tracing;
namespace Volo.Abp.AspNetCore.Tracing
{
public class AbpCorrelationIdMiddleware
{
private readonly RequestDelegate _next;
public AbpCorrelationIdMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(
HttpContext httpContext,
IOptions<CorrelationIdOptions> options,
ICorrelationIdProvider correlationIdProvider)
{
var correlationId = correlationIdProvider.Get();
var optionsValue = options.Value;
try
{
await _next(httpContext);
}
finally
{
CheckAndSetCorrelationIdOnResponse(httpContext, optionsValue, correlationId);
}
}
protected virtual void CheckAndSetCorrelationIdOnResponse(
HttpContext httpContext,
CorrelationIdOptions options,
string correlationId)
{
if (httpContext.Response.HasStarted)
{
return;
}
if (!options.SetResponseHeader)
{
return;
}
if (httpContext.Response.Headers.ContainsKey(options.HttpHeaderName))
{
return;
}
httpContext.Response.Headers[options.HttpHeaderName] = correlationId;
}
}
}

@ -3,5 +3,7 @@
public class CorrelationIdOptions
{
public string HttpHeaderName { get; set; } = "X-Correlation-Id";
public bool SetResponseHeader { get; set; } = true;
}
}

@ -82,6 +82,7 @@ namespace Volo.Abp.AspNetCore.Mvc
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseMiddleware<FakeAuthenticationMiddleware>();
app.UseAuditing();
app.UseUnitOfWork();

@ -73,6 +73,7 @@ namespace AuthServer.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseIdentityServer();
app.UseAbpRequestLocalization();

@ -89,6 +89,7 @@ namespace BackendAdminApp.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseAbpRequestLocalization();

@ -81,6 +81,7 @@ namespace PublicWebSite.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseAbpRequestLocalization();

@ -81,6 +81,7 @@ namespace BackendAdminAppGateway.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseSwagger();

@ -70,6 +70,7 @@ namespace InternalGateway.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseSwagger();

@ -70,6 +70,7 @@ namespace PublicWebSiteGateway.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseSwagger();

@ -93,6 +93,7 @@ namespace BloggingService.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseAbpRequestLocalization(); //TODO: localization?

@ -84,6 +84,7 @@ namespace IdentityService.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseAbpRequestLocalization(); //TODO: localization?

@ -84,6 +84,7 @@ namespace ProductService.Host
{
var app = context.GetApplicationBuilder();
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseAuthentication();
app.UseAbpRequestLocalization(); //TODO: localization?

Loading…
Cancel
Save