mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
removed null admin path hack (#513)
This commit is contained in:
parent
049731b43b
commit
29ff0045fe
@ -10,6 +10,7 @@ using Ocelot.Configuration.Validator;
|
|||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
@ -49,14 +50,14 @@ namespace Ocelot.Configuration.Creator
|
|||||||
IRateLimitOptionsCreator rateLimitOptionsCreator,
|
IRateLimitOptionsCreator rateLimitOptionsCreator,
|
||||||
IRegionCreator regionCreator,
|
IRegionCreator regionCreator,
|
||||||
IHttpHandlerOptionsCreator httpHandlerOptionsCreator,
|
IHttpHandlerOptionsCreator httpHandlerOptionsCreator,
|
||||||
IAdministrationPath adminPath,
|
IServiceProvider serviceProvider,
|
||||||
IHeaderFindAndReplaceCreator headerFAndRCreator,
|
IHeaderFindAndReplaceCreator headerFAndRCreator,
|
||||||
IDownstreamAddressesCreator downstreamAddressesCreator
|
IDownstreamAddressesCreator downstreamAddressesCreator
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_downstreamAddressesCreator = downstreamAddressesCreator;
|
_downstreamAddressesCreator = downstreamAddressesCreator;
|
||||||
_headerFAndRCreator = headerFAndRCreator;
|
_headerFAndRCreator = headerFAndRCreator;
|
||||||
_adminPath = adminPath;
|
_adminPath = serviceProvider.GetService<IAdministrationPath>();
|
||||||
_regionCreator = regionCreator;
|
_regionCreator = regionCreator;
|
||||||
_rateLimitOptionsCreator = rateLimitOptionsCreator;
|
_rateLimitOptionsCreator = rateLimitOptionsCreator;
|
||||||
_requestIdKeyCreator = requestIdKeyCreator;
|
_requestIdKeyCreator = requestIdKeyCreator;
|
||||||
@ -117,8 +118,10 @@ namespace Ocelot.Configuration.Creator
|
|||||||
|
|
||||||
var httpHandlerOptions = _httpHandlerOptionsCreator.Create(fileConfiguration.GlobalConfiguration.HttpHandlerOptions);
|
var httpHandlerOptions = _httpHandlerOptionsCreator.Create(fileConfiguration.GlobalConfiguration.HttpHandlerOptions);
|
||||||
|
|
||||||
|
var adminPath = _adminPath != null ? _adminPath.Path : null;
|
||||||
|
|
||||||
var config = new InternalConfiguration(reRoutes,
|
var config = new InternalConfiguration(reRoutes,
|
||||||
_adminPath.Path,
|
adminPath,
|
||||||
serviceProviderConfiguration,
|
serviceProviderConfiguration,
|
||||||
fileConfiguration.GlobalConfiguration.RequestIdKey,
|
fileConfiguration.GlobalConfiguration.RequestIdKey,
|
||||||
lbOptions,
|
lbOptions,
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
namespace Ocelot.DependencyInjection
|
|
||||||
{
|
|
||||||
public class NullAdministrationPath : IAdministrationPath
|
|
||||||
{
|
|
||||||
public NullAdministrationPath()
|
|
||||||
{
|
|
||||||
Path = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Path {get;private set;}
|
|
||||||
}
|
|
||||||
}
|
|
@ -152,12 +152,10 @@ namespace Ocelot.DependencyInjection
|
|||||||
_services.AddLogging();
|
_services.AddLogging();
|
||||||
_services.AddMiddlewareAnalysis();
|
_services.AddMiddlewareAnalysis();
|
||||||
_services.AddWebEncoders();
|
_services.AddWebEncoders();
|
||||||
_services.AddSingleton<IAdministrationPath>(new NullAdministrationPath());
|
|
||||||
|
|
||||||
_services.TryAddSingleton<IMultiplexer, Multiplexer>();
|
_services.TryAddSingleton<IMultiplexer, Multiplexer>();
|
||||||
_services.TryAddSingleton<IResponseAggregator, SimpleJsonResponseAggregator>();
|
_services.TryAddSingleton<IResponseAggregator, SimpleJsonResponseAggregator>();
|
||||||
_services.AddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
|
_services.AddSingleton<ITracingHandlerFactory, TracingHandlerFactory>();
|
||||||
|
|
||||||
_services.TryAddSingleton<IFileConfigurationPollerOptions, InMemoryFileConfigurationPollerOptions>();
|
_services.TryAddSingleton<IFileConfigurationPollerOptions, InMemoryFileConfigurationPollerOptions>();
|
||||||
_services.TryAddSingleton<IAddHeadersToResponse, AddHeadersToResponse>();
|
_services.TryAddSingleton<IAddHeadersToResponse, AddHeadersToResponse>();
|
||||||
_services.TryAddSingleton<IPlaceholders, Placeholders>();
|
_services.TryAddSingleton<IPlaceholders, Placeholders>();
|
||||||
@ -180,8 +178,7 @@ namespace Ocelot.DependencyInjection
|
|||||||
AddIdentityServer(identityServerConfiguration, administrationPath);
|
AddIdentityServer(identityServerConfiguration, administrationPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var descriptor = new ServiceDescriptor(typeof(IAdministrationPath), administrationPath);
|
_services.AddSingleton<IAdministrationPath>(administrationPath);
|
||||||
_services.Replace(descriptor);
|
|
||||||
return new OcelotAdministrationBuilder(_services, _configurationRoot);
|
return new OcelotAdministrationBuilder(_services, _configurationRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,9 +191,7 @@ namespace Ocelot.DependencyInjection
|
|||||||
AddIdentityServer(configureOptions);
|
AddIdentityServer(configureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo - hack because we add this earlier so it always exists for some reason...investigate..
|
_services.AddSingleton<IAdministrationPath>(administrationPath);
|
||||||
var descriptor = new ServiceDescriptor(typeof(IAdministrationPath), administrationPath);
|
|
||||||
_services.Replace(descriptor);
|
|
||||||
return new OcelotAdministrationBuilder(_services, _configurationRoot);
|
return new OcelotAdministrationBuilder(_services, _configurationRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
|
|
||||||
private static bool AdministrationApiInUse(IAdministrationPath adminPath)
|
private static bool AdministrationApiInUse(IAdministrationPath adminPath)
|
||||||
{
|
{
|
||||||
return adminPath.GetType() != typeof(NullAdministrationPath);
|
return adminPath != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task SetFileConfigInConsul(IApplicationBuilder builder,
|
private static async Task SetFileConfigInConsul(IApplicationBuilder builder,
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
private readonly Mock<IRateLimitOptionsCreator> _rateLimitOptions;
|
private readonly Mock<IRateLimitOptionsCreator> _rateLimitOptions;
|
||||||
private readonly Mock<IRegionCreator> _regionCreator;
|
private readonly Mock<IRegionCreator> _regionCreator;
|
||||||
private readonly Mock<IHttpHandlerOptionsCreator> _httpHandlerOptionsCreator;
|
private readonly Mock<IHttpHandlerOptionsCreator> _httpHandlerOptionsCreator;
|
||||||
private readonly Mock<IAdministrationPath> _adminPath;
|
private readonly Mock<IServiceProvider> _serviceProvider;
|
||||||
private readonly Mock<IHeaderFindAndReplaceCreator> _headerFindAndReplaceCreator;
|
private readonly Mock<IHeaderFindAndReplaceCreator> _headerFindAndReplaceCreator;
|
||||||
private readonly Mock<IDownstreamAddressesCreator> _downstreamAddressesCreator;
|
private readonly Mock<IDownstreamAddressesCreator> _downstreamAddressesCreator;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@
|
|||||||
_rateLimitOptions = new Mock<IRateLimitOptionsCreator>();
|
_rateLimitOptions = new Mock<IRateLimitOptionsCreator>();
|
||||||
_regionCreator = new Mock<IRegionCreator>();
|
_regionCreator = new Mock<IRegionCreator>();
|
||||||
_httpHandlerOptionsCreator = new Mock<IHttpHandlerOptionsCreator>();
|
_httpHandlerOptionsCreator = new Mock<IHttpHandlerOptionsCreator>();
|
||||||
_adminPath = new Mock<IAdministrationPath>();
|
_serviceProvider = new Mock<IServiceProvider>();
|
||||||
_headerFindAndReplaceCreator = new Mock<IHeaderFindAndReplaceCreator>();
|
_headerFindAndReplaceCreator = new Mock<IHeaderFindAndReplaceCreator>();
|
||||||
_downstreamAddressesCreator = new Mock<IDownstreamAddressesCreator>();
|
_downstreamAddressesCreator = new Mock<IDownstreamAddressesCreator>();
|
||||||
|
|
||||||
@ -71,7 +71,7 @@
|
|||||||
_rateLimitOptions.Object,
|
_rateLimitOptions.Object,
|
||||||
_regionCreator.Object,
|
_regionCreator.Object,
|
||||||
_httpHandlerOptionsCreator.Object,
|
_httpHandlerOptionsCreator.Object,
|
||||||
_adminPath.Object,
|
_serviceProvider.Object,
|
||||||
_headerFindAndReplaceCreator.Object,
|
_headerFindAndReplaceCreator.Object,
|
||||||
_downstreamAddressesCreator.Object);
|
_downstreamAddressesCreator.Object);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user