mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
remove bak file
This commit is contained in:
parent
ab6ae8a062
commit
f302ee77bf
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"projects": [ "src", "test" ],
|
"projects": [ "src", "test" ],
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "1.0.0-preview2-003131"
|
"version": "1.0.0-preview2-003133"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,356 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Ocelot.Configuration.Builder;
|
|
||||||
using Ocelot.Configuration.File;
|
|
||||||
using Ocelot.Configuration.Parser;
|
|
||||||
using Ocelot.Configuration.Validator;
|
|
||||||
using Ocelot.LoadBalancer.LoadBalancers;
|
|
||||||
using Ocelot.Requester.QoS;
|
|
||||||
using Ocelot.Responses;
|
|
||||||
using Ocelot.Utilities;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Register as singleton
|
|
||||||
/// </summary>
|
|
||||||
public class FileOcelotConfigurationCreator : IOcelotConfigurationCreator
|
|
||||||
{
|
|
||||||
private readonly IOptions<FileConfiguration> _options;
|
|
||||||
private readonly IConfigurationValidator _configurationValidator;
|
|
||||||
private const string RegExMatchEverything = ".*";
|
|
||||||
private const string RegExMatchEndString = "$";
|
|
||||||
private const string RegExIgnoreCase = "(?i)";
|
|
||||||
private const string RegExForwardSlashOnly = "^/$";
|
|
||||||
|
|
||||||
private readonly IClaimToThingConfigurationParser _claimToThingConfigurationParser;
|
|
||||||
private readonly ILogger<FileOcelotConfigurationCreator> _logger;
|
|
||||||
private readonly ILoadBalancerFactory _loadBalanceFactory;
|
|
||||||
private readonly ILoadBalancerHouse _loadBalancerHouse;
|
|
||||||
private readonly IQoSProviderFactory _qoSProviderFactory;
|
|
||||||
private readonly IQosProviderHouse _qosProviderHouse;
|
|
||||||
|
|
||||||
public FileOcelotConfigurationCreator(
|
|
||||||
IOptions<FileConfiguration> options,
|
|
||||||
IConfigurationValidator configurationValidator,
|
|
||||||
IClaimToThingConfigurationParser claimToThingConfigurationParser,
|
|
||||||
ILogger<FileOcelotConfigurationCreator> logger,
|
|
||||||
ILoadBalancerFactory loadBalancerFactory,
|
|
||||||
ILoadBalancerHouse loadBalancerHouse,
|
|
||||||
IQoSProviderFactory qoSProviderFactory,
|
|
||||||
IQosProviderHouse qosProviderHouse)
|
|
||||||
{
|
|
||||||
_loadBalanceFactory = loadBalancerFactory;
|
|
||||||
_loadBalancerHouse = loadBalancerHouse;
|
|
||||||
_qoSProviderFactory = qoSProviderFactory;
|
|
||||||
_qosProviderHouse = qosProviderHouse;
|
|
||||||
_options = options;
|
|
||||||
_configurationValidator = configurationValidator;
|
|
||||||
_claimToThingConfigurationParser = claimToThingConfigurationParser;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Response<IOcelotConfiguration>> Create()
|
|
||||||
{
|
|
||||||
var config = await SetUpConfiguration();
|
|
||||||
|
|
||||||
return new OkResponse<IOcelotConfiguration>(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<IOcelotConfiguration> SetUpConfiguration()
|
|
||||||
{
|
|
||||||
var response = _configurationValidator.IsValid(_options.Value);
|
|
||||||
|
|
||||||
if (response.Data.IsError)
|
|
||||||
{
|
|
||||||
var errorBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (var error in response.Errors)
|
|
||||||
{
|
|
||||||
errorBuilder.AppendLine(error.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception($"Unable to start Ocelot..configuration, errors were {errorBuilder}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var reRoutes = new List<ReRoute>();
|
|
||||||
|
|
||||||
foreach (var reRoute in _options.Value.ReRoutes)
|
|
||||||
{
|
|
||||||
var ocelotReRoute = await SetUpReRoute(reRoute, _options.Value.GlobalConfiguration);
|
|
||||||
reRoutes.Add(ocelotReRoute);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OcelotConfiguration(reRoutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<ReRoute> SetUpReRoute(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
|
|
||||||
{
|
|
||||||
var isAuthenticated = IsAuthenticated(fileReRoute);
|
|
||||||
|
|
||||||
var isAuthorised = IsAuthorised(fileReRoute);
|
|
||||||
|
|
||||||
var isCached = IsCached(fileReRoute);
|
|
||||||
|
|
||||||
var requestIdKey = BuildRequestId(fileReRoute, globalConfiguration);
|
|
||||||
|
|
||||||
var reRouteKey = BuildReRouteKey(fileReRoute);
|
|
||||||
|
|
||||||
var upstreamTemplatePattern = BuildUpstreamTemplatePattern(fileReRoute);
|
|
||||||
|
|
||||||
var isQos = IsQoS(fileReRoute);
|
|
||||||
|
|
||||||
var serviceProviderConfiguration = BuildServiceProviderConfiguration(fileReRoute, globalConfiguration);
|
|
||||||
|
|
||||||
var authOptionsForRoute = BuildAuthenticationOptions(fileReRoute);
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
ReRoute reRoute;
|
|
||||||
|
|
||||||
var enableRateLimiting = (fileReRoute.RateLimitOptions!= null && fileReRoute.RateLimitOptions.EnableRateLimiting)? true: false;
|
|
||||||
RateLimitOptions rateLimitOption = null;
|
|
||||||
if (enableRateLimiting)
|
|
||||||
{
|
|
||||||
rateLimitOption = new RateLimitOptions(enableRateLimiting, globalConfiguration.RateLimitOptions.ClientIdHeader,
|
|
||||||
fileReRoute.RateLimitOptions.ClientWhitelist, globalConfiguration.RateLimitOptions.DisableRateLimitHeaders,
|
|
||||||
globalConfiguration.RateLimitOptions.QuotaExceededMessage, globalConfiguration.RateLimitOptions.RateLimitCounterPrefix,
|
|
||||||
new RateLimitRule(fileReRoute.RateLimitOptions.Period, TimeSpan.FromSeconds(fileReRoute.RateLimitOptions.PeriodTimespan), fileReRoute.RateLimitOptions.Limit)
|
|
||||||
, globalConfiguration.RateLimitOptions.HttpStatusCode);
|
|
||||||
}
|
|
||||||
var serviceProviderPort = globalConfiguration?.ServiceDiscoveryProvider?.Port ?? 0;
|
|
||||||
=======
|
|
||||||
var claimsToHeaders = BuildAddThingsToRequest(fileReRoute.AddHeadersToRequest);
|
|
||||||
|
|
||||||
var claimsToClaims = BuildAddThingsToRequest(fileReRoute.AddClaimsToRequest);
|
|
||||||
|
|
||||||
var claimsToQueries = BuildAddThingsToRequest(fileReRoute.AddQueriesToRequest);
|
|
||||||
|
|
||||||
var qosOptions = BuildQoSOptions(fileReRoute);
|
|
||||||
|
|
||||||
var reRoute = new ReRouteBuilder()
|
|
||||||
.WithDownstreamPathTemplate(fileReRoute.DownstreamPathTemplate)
|
|
||||||
.WithUpstreamPathTemplate(fileReRoute.UpstreamPathTemplate)
|
|
||||||
.WithUpstreamHttpMethod(fileReRoute.UpstreamHttpMethod)
|
|
||||||
.WithUpstreamTemplatePattern(upstreamTemplatePattern)
|
|
||||||
.WithIsAuthenticated(isAuthenticated)
|
|
||||||
.WithAuthenticationOptions(authOptionsForRoute)
|
|
||||||
.WithClaimsToHeaders(claimsToHeaders)
|
|
||||||
.WithClaimsToClaims(claimsToClaims)
|
|
||||||
.WithRouteClaimsRequirement(fileReRoute.RouteClaimsRequirement)
|
|
||||||
.WithIsAuthorised(isAuthorised)
|
|
||||||
.WithClaimsToQueries(claimsToQueries)
|
|
||||||
.WithRequestIdKey(requestIdKey)
|
|
||||||
.WithIsCached(isCached)
|
|
||||||
.WithCacheOptions(new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds))
|
|
||||||
.WithDownstreamScheme(fileReRoute.DownstreamScheme)
|
|
||||||
.WithLoadBalancer(fileReRoute.LoadBalancer)
|
|
||||||
.WithDownstreamHost(fileReRoute.DownstreamHost)
|
|
||||||
.WithDownstreamPort(fileReRoute.DownstreamPort)
|
|
||||||
.WithLoadBalancerKey(reRouteKey)
|
|
||||||
.WithServiceProviderConfiguraion(serviceProviderConfiguration)
|
|
||||||
.WithIsQos(isQos)
|
|
||||||
.WithQosOptions(qosOptions)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
await SetupLoadBalancer(reRoute);
|
|
||||||
SetupQosProvider(reRoute);
|
|
||||||
return reRoute;
|
|
||||||
}
|
|
||||||
|
|
||||||
private QoSOptions BuildQoSOptions(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return new QoSOptionsBuilder()
|
|
||||||
.WithExceptionsAllowedBeforeBreaking(fileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking)
|
|
||||||
.WithDurationOfBreak(fileReRoute.QoSOptions.DurationOfBreak)
|
|
||||||
.WithTimeoutValue(fileReRoute.QoSOptions.TimeoutValue)
|
|
||||||
.Build();
|
|
||||||
}
|
|
||||||
>>>>>>> refs/remotes/origin/develop
|
|
||||||
|
|
||||||
private bool IsQoS(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return fileReRoute.QoSOptions?.ExceptionsAllowedBeforeBreaking > 0 && fileReRoute.QoSOptions?.TimeoutValue > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (isAuthenticated)
|
|
||||||
{
|
|
||||||
var authOptionsForRoute = new AuthenticationOptions(fileReRoute.AuthenticationOptions.Provider,
|
|
||||||
fileReRoute.AuthenticationOptions.ProviderRootUrl, fileReRoute.AuthenticationOptions.ScopeName,
|
|
||||||
fileReRoute.AuthenticationOptions.RequireHttps, fileReRoute.AuthenticationOptions.AdditionalScopes,
|
|
||||||
fileReRoute.AuthenticationOptions.ScopeSecret);
|
|
||||||
|
|
||||||
var claimsToHeaders = GetAddThingsToRequest(fileReRoute.AddHeadersToRequest);
|
|
||||||
var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
|
|
||||||
var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
|
|
||||||
|
|
||||||
reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
|
|
||||||
fileReRoute.UpstreamTemplate,
|
|
||||||
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
|
||||||
authOptionsForRoute, claimsToHeaders, claimsToClaims,
|
|
||||||
fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
|
|
||||||
requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
|
|
||||||
, fileReRoute.DownstreamScheme,
|
|
||||||
fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
|
|
||||||
serviceProviderConfiguration, isQos,
|
|
||||||
new QoSOptions(fileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking, fileReRoute.QoSOptions.DurationOfBreak, fileReRoute.QoSOptions.TimeoutValue),
|
|
||||||
enableRateLimiting, rateLimitOption);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
|
|
||||||
fileReRoute.UpstreamTemplate,
|
|
||||||
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
|
||||||
null, new List<ClaimToThing>(), new List<ClaimToThing>(),
|
|
||||||
fileReRoute.RouteClaimsRequirement, isAuthorised, new List<ClaimToThing>(),
|
|
||||||
requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds),
|
|
||||||
fileReRoute.DownstreamScheme,
|
|
||||||
fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
|
|
||||||
serviceProviderConfiguration, isQos,
|
|
||||||
new QoSOptions(fileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking, fileReRoute.QoSOptions.DurationOfBreak, fileReRoute.QoSOptions.TimeoutValue),
|
|
||||||
enableRateLimiting, rateLimitOption);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
private bool IsAuthenticated(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return !string.IsNullOrEmpty(fileReRoute.AuthenticationOptions?.Provider);
|
|
||||||
}
|
|
||||||
>>>>>>> refs/remotes/origin/develop
|
|
||||||
|
|
||||||
private bool IsAuthorised(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return fileReRoute.RouteClaimsRequirement?.Count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsCached(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return fileReRoute.FileCacheOptions.TtlSeconds > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string BuildRequestId(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
|
|
||||||
{
|
|
||||||
var globalRequestIdConfiguration = !string.IsNullOrEmpty(globalConfiguration?.RequestIdKey);
|
|
||||||
|
|
||||||
var requestIdKey = globalRequestIdConfiguration
|
|
||||||
? globalConfiguration.RequestIdKey
|
|
||||||
: fileReRoute.RequestIdKey;
|
|
||||||
|
|
||||||
return requestIdKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string BuildReRouteKey(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
//note - not sure if this is the correct key, but this is probably the only unique key i can think of given my poor brain
|
|
||||||
var loadBalancerKey = $"{fileReRoute.UpstreamPathTemplate}{fileReRoute.UpstreamHttpMethod}";
|
|
||||||
return loadBalancerKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AuthenticationOptions BuildAuthenticationOptions(FileReRoute fileReRoute)
|
|
||||||
{
|
|
||||||
return new AuthenticationOptionsBuilder()
|
|
||||||
.WithProvider(fileReRoute.AuthenticationOptions?.Provider)
|
|
||||||
.WithProviderRootUrl(fileReRoute.AuthenticationOptions?.ProviderRootUrl)
|
|
||||||
.WithScopeName(fileReRoute.AuthenticationOptions?.ScopeName)
|
|
||||||
.WithRequireHttps(fileReRoute.AuthenticationOptions.RequireHttps)
|
|
||||||
.WithAdditionalScopes(fileReRoute.AuthenticationOptions?.AdditionalScopes)
|
|
||||||
.WithScopeSecret(fileReRoute.AuthenticationOptions?.ScopeSecret)
|
|
||||||
.Build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SetupLoadBalancer(ReRoute reRoute)
|
|
||||||
{
|
|
||||||
var loadBalancer = await _loadBalanceFactory.Get(reRoute);
|
|
||||||
_loadBalancerHouse.Add(reRoute.ReRouteKey, loadBalancer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetupQosProvider(ReRoute reRoute)
|
|
||||||
{
|
|
||||||
var loadBalancer = _qoSProviderFactory.Get(reRoute);
|
|
||||||
_qosProviderHouse.Add(reRoute.ReRouteKey, loadBalancer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceProviderConfiguraion BuildServiceProviderConfiguration(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
|
|
||||||
{
|
|
||||||
var useServiceDiscovery = !string.IsNullOrEmpty(fileReRoute.ServiceName)
|
|
||||||
&& !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Provider);
|
|
||||||
|
|
||||||
var serviceProviderPort = globalConfiguration?.ServiceDiscoveryProvider?.Port ?? 0;
|
|
||||||
|
|
||||||
return new ServiceProviderConfiguraionBuilder()
|
|
||||||
.WithServiceName(fileReRoute.ServiceName)
|
|
||||||
.WithDownstreamHost(fileReRoute.DownstreamHost)
|
|
||||||
.WithDownstreamPort(fileReRoute.DownstreamPort)
|
|
||||||
.WithUseServiceDiscovery(useServiceDiscovery)
|
|
||||||
.WithServiceDiscoveryProvider(globalConfiguration?.ServiceDiscoveryProvider?.Provider)
|
|
||||||
.WithServiceDiscoveryProviderHost(globalConfiguration?.ServiceDiscoveryProvider?.Host)
|
|
||||||
.WithServiceDiscoveryProviderPort(serviceProviderPort)
|
|
||||||
.Build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string BuildUpstreamTemplatePattern(FileReRoute reRoute)
|
|
||||||
{
|
|
||||||
var upstreamTemplate = reRoute.UpstreamPathTemplate;
|
|
||||||
|
|
||||||
upstreamTemplate = upstreamTemplate.SetLastCharacterAs('/');
|
|
||||||
|
|
||||||
var placeholders = new List<string>();
|
|
||||||
|
|
||||||
for (var i = 0; i < upstreamTemplate.Length; i++)
|
|
||||||
{
|
|
||||||
if (IsPlaceHolder(upstreamTemplate, i))
|
|
||||||
{
|
|
||||||
var postitionOfPlaceHolderClosingBracket = upstreamTemplate.IndexOf('}', i);
|
|
||||||
var difference = postitionOfPlaceHolderClosingBracket - i + 1;
|
|
||||||
var variableName = upstreamTemplate.Substring(i, difference);
|
|
||||||
placeholders.Add(variableName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var placeholder in placeholders)
|
|
||||||
{
|
|
||||||
upstreamTemplate = upstreamTemplate.Replace(placeholder, RegExMatchEverything);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (upstreamTemplate == "/")
|
|
||||||
{
|
|
||||||
return RegExForwardSlashOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
var route = reRoute.ReRouteIsCaseSensitive
|
|
||||||
? $"{upstreamTemplate}{RegExMatchEndString}"
|
|
||||||
: $"{RegExIgnoreCase}{upstreamTemplate}{RegExMatchEndString}";
|
|
||||||
|
|
||||||
return route;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ClaimToThing> BuildAddThingsToRequest(Dictionary<string,string> thingBeingAdded)
|
|
||||||
{
|
|
||||||
var claimsToTHings = new List<ClaimToThing>();
|
|
||||||
|
|
||||||
foreach (var add in thingBeingAdded)
|
|
||||||
{
|
|
||||||
var claimToHeader = _claimToThingConfigurationParser.Extract(add.Key, add.Value);
|
|
||||||
|
|
||||||
if (claimToHeader.IsError)
|
|
||||||
{
|
|
||||||
_logger.LogCritical(new EventId(1, "Application Failed to start"),
|
|
||||||
$"Unable to extract configuration for key: {add.Key} and value: {add.Value} your configuration file is incorrect");
|
|
||||||
|
|
||||||
throw new Exception(claimToHeader.Errors[0].Message);
|
|
||||||
}
|
|
||||||
claimsToTHings.Add(claimToHeader.Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return claimsToTHings;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsPlaceHolder(string upstreamTemplate, int i)
|
|
||||||
{
|
|
||||||
return upstreamTemplate[i] == '{';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
using Polly.Timeout;
|
|
||||||
using System;
|
|
||||||
=======
|
|
||||||
using System;
|
|
||||||
using Polly.Timeout;
|
|
||||||
>>>>>>> refs/remotes/origin/develop
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
|
||||||
{
|
|
||||||
public class QoSOptions
|
|
||||||
{
|
|
||||||
public QoSOptions(
|
|
||||||
int exceptionsAllowedBeforeBreaking,
|
|
||||||
int durationofBreak,
|
|
||||||
int timeoutValue,
|
|
||||||
TimeoutStrategy timeoutStrategy = TimeoutStrategy.Pessimistic)
|
|
||||||
{
|
|
||||||
ExceptionsAllowedBeforeBreaking = exceptionsAllowedBeforeBreaking;
|
|
||||||
DurationOfBreak = TimeSpan.FromMilliseconds(durationofBreak);
|
|
||||||
TimeoutValue = TimeSpan.FromMilliseconds(timeoutValue);
|
|
||||||
TimeoutStrategy = timeoutStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int ExceptionsAllowedBeforeBreaking { get; private set; }
|
|
||||||
|
|
||||||
public TimeSpan DurationOfBreak { get; private set; }
|
|
||||||
|
|
||||||
public TimeSpan TimeoutValue { get; private set; }
|
|
||||||
|
|
||||||
public TimeoutStrategy TimeoutStrategy { get; private set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using Ocelot.Values;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
|
||||||
{
|
|
||||||
public class ReRoute
|
|
||||||
{
|
|
||||||
public ReRoute(PathTemplate downstreamPathTemplate,
|
|
||||||
PathTemplate upstreamTemplate,
|
|
||||||
HttpMethod upstreamHttpMethod,
|
|
||||||
string upstreamTemplatePattern,
|
|
||||||
bool isAuthenticated,
|
|
||||||
AuthenticationOptions authenticationOptions,
|
|
||||||
List<ClaimToThing> configurationHeaderExtractorProperties,
|
|
||||||
List<ClaimToThing> claimsToClaims,
|
|
||||||
Dictionary<string, string> routeClaimsRequirement,
|
|
||||||
bool isAuthorised,
|
|
||||||
List<ClaimToThing> claimsToQueries,
|
|
||||||
<<<<<<< HEAD
|
|
||||||
string requestIdKey, bool isCached, CacheOptions fileCacheOptions,
|
|
||||||
string downstreamScheme, string loadBalancer, string downstreamHost,
|
|
||||||
int downstreamPort, string loadBalancerKey, ServiceProviderConfiguraion serviceProviderConfiguraion,
|
|
||||||
bool isQos,QoSOptions qos, bool enableRateLimit, RateLimitOptions ratelimitOptions)
|
|
||||||
=======
|
|
||||||
string requestIdKey,
|
|
||||||
bool isCached,
|
|
||||||
CacheOptions fileCacheOptions,
|
|
||||||
string downstreamScheme,
|
|
||||||
string loadBalancer,
|
|
||||||
string downstreamHost,
|
|
||||||
int downstreamPort,
|
|
||||||
string reRouteKey,
|
|
||||||
ServiceProviderConfiguraion serviceProviderConfiguraion,
|
|
||||||
bool isQos,
|
|
||||||
QoSOptions qos)
|
|
||||||
>>>>>>> refs/remotes/origin/develop
|
|
||||||
{
|
|
||||||
ReRouteKey = reRouteKey;
|
|
||||||
ServiceProviderConfiguraion = serviceProviderConfiguraion;
|
|
||||||
LoadBalancer = loadBalancer;
|
|
||||||
DownstreamHost = downstreamHost;
|
|
||||||
DownstreamPort = downstreamPort;
|
|
||||||
DownstreamPathTemplate = downstreamPathTemplate;
|
|
||||||
UpstreamPathTemplate = upstreamTemplate;
|
|
||||||
UpstreamHttpMethod = upstreamHttpMethod;
|
|
||||||
UpstreamTemplatePattern = upstreamTemplatePattern;
|
|
||||||
IsAuthenticated = isAuthenticated;
|
|
||||||
AuthenticationOptions = authenticationOptions;
|
|
||||||
RouteClaimsRequirement = routeClaimsRequirement;
|
|
||||||
IsAuthorised = isAuthorised;
|
|
||||||
RequestIdKey = requestIdKey;
|
|
||||||
IsCached = isCached;
|
|
||||||
FileCacheOptions = fileCacheOptions;
|
|
||||||
ClaimsToQueries = claimsToQueries
|
|
||||||
?? new List<ClaimToThing>();
|
|
||||||
ClaimsToClaims = claimsToClaims
|
|
||||||
?? new List<ClaimToThing>();
|
|
||||||
ClaimsToHeaders = configurationHeaderExtractorProperties
|
|
||||||
?? new List<ClaimToThing>();
|
|
||||||
DownstreamScheme = downstreamScheme;
|
|
||||||
IsQos = isQos;
|
|
||||||
QosOptions = qos;
|
|
||||||
EnableEndpointRateLimiting = enableRateLimit;
|
|
||||||
RateLimitOptions = ratelimitOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ReRouteKey {get;private set;}
|
|
||||||
public PathTemplate DownstreamPathTemplate { get; private set; }
|
|
||||||
public PathTemplate UpstreamPathTemplate { get; private set; }
|
|
||||||
public string UpstreamTemplatePattern { get; private set; }
|
|
||||||
public HttpMethod UpstreamHttpMethod { get; private set; }
|
|
||||||
public bool IsAuthenticated { get; private set; }
|
|
||||||
public bool IsAuthorised { get; private set; }
|
|
||||||
public AuthenticationOptions AuthenticationOptions { get; private set; }
|
|
||||||
public List<ClaimToThing> ClaimsToQueries { get; private set; }
|
|
||||||
public List<ClaimToThing> ClaimsToHeaders { get; private set; }
|
|
||||||
public List<ClaimToThing> ClaimsToClaims { get; private set; }
|
|
||||||
public Dictionary<string, string> RouteClaimsRequirement { get; private set; }
|
|
||||||
public string RequestIdKey { get; private set; }
|
|
||||||
public bool IsCached { get; private set; }
|
|
||||||
public CacheOptions FileCacheOptions { get; private set; }
|
|
||||||
public string DownstreamScheme {get;private set;}
|
|
||||||
public bool IsQos { get; private set; }
|
|
||||||
public QoSOptions QosOptions { get; private set; }
|
|
||||||
public string LoadBalancer {get;private set;}
|
|
||||||
public string DownstreamHost { get; private set; }
|
|
||||||
public int DownstreamPort { get; private set; }
|
|
||||||
public ServiceProviderConfiguraion ServiceProviderConfiguraion { get; private set; }
|
|
||||||
public bool EnableEndpointRateLimiting { get; private set; }
|
|
||||||
public RateLimitOptions RateLimitOptions { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +1 @@
|
|||||||
{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}}
|
{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamPathTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":null,"RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":null,"PeriodTimespan":0.0,"Limit":0}}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0},"RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":null,"RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}}
|
Loading…
x
Reference in New Issue
Block a user