React to IRequestIdentifierFeature refactor.
This commit is contained in:
parent
736e6bee2b
commit
2c43b350b4
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
|
||||
namespace Microsoft.AspNet.Hosting
|
||||
{
|
||||
public class DefaultRequestIdentifierFeature : IRequestIdentifierFeature
|
||||
{
|
||||
public DefaultRequestIdentifierFeature()
|
||||
{
|
||||
TraceIdentifier = Guid.NewGuid();
|
||||
}
|
||||
|
||||
public Guid TraceIdentifier { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ using Microsoft.AspNet.Hosting.Server;
|
|||
using Microsoft.AspNet.Hosting.Startup;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Http.Features.Internal;
|
||||
using Microsoft.Framework.Configuration;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
|
@ -158,12 +159,15 @@ namespace Microsoft.AspNet.Hosting.Internal
|
|||
return builder.Build();
|
||||
}
|
||||
|
||||
private Guid GetRequestIdentifier(HttpContext httpContext)
|
||||
private string GetRequestIdentifier(HttpContext httpContext)
|
||||
{
|
||||
var requestIdentifierFeature = httpContext.GetFeature<IRequestIdentifierFeature>();
|
||||
var requestIdentifierFeature = httpContext.GetFeature<IHttpRequestIdentifierFeature>();
|
||||
if (requestIdentifierFeature == null)
|
||||
{
|
||||
requestIdentifierFeature = new DefaultRequestIdentifierFeature();
|
||||
requestIdentifierFeature = new HttpRequestIdentifierFeature()
|
||||
{
|
||||
TraceIdentifier = Guid.NewGuid().ToString()
|
||||
};
|
||||
httpContext.SetFeature(requestIdentifierFeature);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Microsoft.AspNet.Hosting.Server;
|
|||
using Microsoft.AspNet.Hosting.Startup;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Http.Features.Internal;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Microsoft.Framework.Configuration;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
|
|
@ -241,7 +242,7 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(httpContext);
|
||||
Assert.IsType<DefaultRequestIdentifierFeature>(httpContext.GetFeature<IRequestIdentifierFeature>());
|
||||
Assert.IsType<HttpRequestIdentifierFeature>(httpContext.GetFeature<IHttpRequestIdentifierFeature>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -270,7 +271,7 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(httpContext);
|
||||
Assert.IsType<DefaultRequestIdentifierFeature>(httpContext.GetFeature<IRequestIdentifierFeature>());
|
||||
Assert.IsType<HttpRequestIdentifierFeature>(httpContext.GetFeature<IHttpRequestIdentifierFeature>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -283,8 +284,8 @@ namespace Microsoft.AspNet.Hosting
|
|||
httpContext = innerHttpContext;
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
var requestIdentifierFeature = new Mock<IRequestIdentifierFeature>().Object;
|
||||
_featuresSupportedByThisHost.Add(typeof(IRequestIdentifierFeature), requestIdentifierFeature);
|
||||
var requestIdentifierFeature = new Mock<IHttpRequestIdentifierFeature>().Object;
|
||||
_featuresSupportedByThisHost.Add(typeof(IHttpRequestIdentifierFeature), requestIdentifierFeature);
|
||||
var hostingEngine = CreateHostingEngine(requestDelegate);
|
||||
|
||||
// Act
|
||||
|
|
@ -292,7 +293,7 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
// Assert
|
||||
Assert.NotNull(httpContext);
|
||||
Assert.Same(requestIdentifierFeature, httpContext.GetFeature<IRequestIdentifierFeature>());
|
||||
Assert.Same(requestIdentifierFeature, httpContext.GetFeature<IHttpRequestIdentifierFeature>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in New Issue