mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
parent
4476f8273e
commit
5d82e68534
@ -4,10 +4,10 @@ namespace Ocelot.Administration
|
|||||||
|
|
||||||
public interface IIdentityServerConfiguration
|
public interface IIdentityServerConfiguration
|
||||||
{
|
{
|
||||||
string ApiName { get; }
|
string ApiName { get; }
|
||||||
string ApiSecret { get; }
|
string ApiSecret { get; }
|
||||||
bool RequireHttps { get; }
|
bool RequireHttps { get; }
|
||||||
List<string> AllowedScopes { get; }
|
List<string> AllowedScopes { get; }
|
||||||
string CredentialsSigningCertificateLocation { get; }
|
string CredentialsSigningCertificateLocation { get; }
|
||||||
string CredentialsSigningCertificatePassword { get; }
|
string CredentialsSigningCertificatePassword { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
namespace Ocelot.Administration
|
namespace Ocelot.Administration
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration;
|
|
||||||
using Configuration.Repository;
|
using Configuration.Repository;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public static class IdentityServerMiddlewareConfigurationProvider
|
public static class IdentityServerMiddlewareConfigurationProvider
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
namespace Ocelot.Administration
|
namespace Ocelot.Administration
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using Configuration;
|
|
||||||
using Configuration.Creator;
|
|
||||||
using DependencyInjection;
|
using DependencyInjection;
|
||||||
using IdentityModel;
|
|
||||||
using IdentityServer4.AccessTokenValidation;
|
using IdentityServer4.AccessTokenValidation;
|
||||||
using IdentityServer4.Models;
|
using IdentityServer4.Models;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@ -16,6 +8,10 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
public static class OcelotBuilderExtensions
|
public static class OcelotBuilderExtensions
|
||||||
{
|
{
|
||||||
@ -61,7 +57,8 @@
|
|||||||
{
|
{
|
||||||
builder.Services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration);
|
builder.Services.TryAddSingleton<IIdentityServerConfiguration>(identityServerConfiguration);
|
||||||
var identityServerBuilder = builder.Services
|
var identityServerBuilder = builder.Services
|
||||||
.AddIdentityServer(o => {
|
.AddIdentityServer(o =>
|
||||||
|
{
|
||||||
o.IssuerUri = "Ocelot";
|
o.IssuerUri = "Ocelot";
|
||||||
})
|
})
|
||||||
.AddInMemoryApiResources(Resources(identityServerConfiguration))
|
.AddInMemoryApiResources(Resources(identityServerConfiguration))
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
namespace Ocelot.Cache.CacheManager
|
namespace Ocelot.Cache.CacheManager
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using Configuration;
|
using Configuration;
|
||||||
using Configuration.File;
|
using Configuration.File;
|
||||||
using DependencyInjection;
|
using DependencyInjection;
|
||||||
using global::CacheManager.Core;
|
using global::CacheManager.Core;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using System;
|
||||||
|
|
||||||
public static class OcelotBuilderExtensions
|
public static class OcelotBuilderExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Ocelot.Cache.CacheManager
|
namespace Ocelot.Cache.CacheManager
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using global::CacheManager.Core;
|
using global::CacheManager.Core;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class OcelotCacheManagerCache<T> : IOcelotCache<T>
|
public class OcelotCacheManagerCache<T> : IOcelotCache<T>
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using global::Consul;
|
using global::Consul;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using Logging;
|
using Logging;
|
||||||
using ServiceDiscovery.Providers;
|
using ServiceDiscovery.Providers;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Values;
|
using Values;
|
||||||
|
|
||||||
|
|
||||||
public class Consul : IServiceDiscoveryProvider
|
public class Consul : IServiceDiscoveryProvider
|
||||||
{
|
{
|
||||||
private readonly ConsulRegistryConfiguration _config;
|
private readonly ConsulRegistryConfiguration _config;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using global::Consul;
|
using global::Consul;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class ConsulClientFactory : IConsulClientFactory
|
public class ConsulClientFactory : IConsulClientFactory
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration.File;
|
using Configuration.File;
|
||||||
using Configuration.Repository;
|
using Configuration.Repository;
|
||||||
using global::Consul;
|
using global::Consul;
|
||||||
using Logging;
|
using Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Responses;
|
using Responses;
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class ConsulFileConfigurationRepository : IFileConfigurationRepository
|
public class ConsulFileConfigurationRepository : IFileConfigurationRepository
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration.Creator;
|
using Configuration.Creator;
|
||||||
using Configuration.File;
|
using Configuration.File;
|
||||||
using Configuration.Repository;
|
using Configuration.Repository;
|
||||||
@ -11,6 +8,9 @@
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using Responses;
|
using Responses;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public static class ConsulMiddlewareConfigurationProvider
|
public static class ConsulMiddlewareConfigurationProvider
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Logging;
|
using Logging;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ServiceDiscovery;
|
using ServiceDiscovery;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Provider.Consul
|
namespace Ocelot.Provider.Consul
|
||||||
{
|
{
|
||||||
|
using Logging;
|
||||||
|
using ServiceDiscovery.Providers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Logging;
|
|
||||||
using ServiceDiscovery.Providers;
|
|
||||||
using Values;
|
using Values;
|
||||||
|
|
||||||
public class PollConsul : IServiceDiscoveryProvider
|
public class PollConsul : IServiceDiscoveryProvider
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Provider.Eureka
|
namespace Ocelot.Provider.Eureka
|
||||||
{
|
{
|
||||||
|
using ServiceDiscovery.Providers;
|
||||||
|
using Steeltoe.Common.Discovery;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ServiceDiscovery.Providers;
|
|
||||||
using Steeltoe.Common.Discovery;
|
|
||||||
using Values;
|
using Values;
|
||||||
|
|
||||||
public class Eureka : IServiceDiscoveryProvider
|
public class Eureka : IServiceDiscoveryProvider
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
namespace Ocelot.Provider.Eureka
|
namespace Ocelot.Provider.Eureka
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration;
|
using Configuration;
|
||||||
using Configuration.Repository;
|
using Configuration.Repository;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using Steeltoe.Discovery.Client;
|
using Steeltoe.Discovery.Client;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class EurekaMiddlewareConfigurationProvider
|
public class EurekaMiddlewareConfigurationProvider
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ServiceDiscovery;
|
using ServiceDiscovery;
|
||||||
using ServiceDiscovery.Providers;
|
|
||||||
using Steeltoe.Common.Discovery;
|
using Steeltoe.Common.Discovery;
|
||||||
|
|
||||||
public static class EurekaProviderFactory
|
public static class EurekaProviderFactory
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
namespace Ocelot.Provider.Eureka
|
namespace Ocelot.Provider.Eureka
|
||||||
{
|
{
|
||||||
using System.Linq;
|
|
||||||
using DependencyInjection;
|
using DependencyInjection;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using Steeltoe.Discovery.Client;
|
|
||||||
using ServiceDiscovery;
|
using ServiceDiscovery;
|
||||||
|
using Steeltoe.Discovery.Client;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public static class OcelotBuilderExtensions
|
public static class OcelotBuilderExtensions
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,6 @@ namespace Ocelot.Provider.Kubernetes
|
|||||||
this.kubeApi = kubeApi;
|
this.kubeApi = kubeApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<Service>> Get()
|
public async Task<List<Service>> Get()
|
||||||
{
|
{
|
||||||
var service = await kubeApi.ServicesV1()
|
var service = await kubeApi.ServicesV1()
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using KubeClient;
|
namespace Ocelot.Provider.Kubernetes
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ocelot.Provider.Kubernetes
|
|
||||||
{
|
{
|
||||||
public class KubeRegistryConfiguration
|
public class KubeRegistryConfiguration
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
|
using Polly;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Polly;
|
|
||||||
using Polly.CircuitBreaker;
|
|
||||||
using Polly.Timeout;
|
|
||||||
|
|
||||||
namespace Ocelot.Provider.Polly
|
namespace Ocelot.Provider.Polly
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
namespace Ocelot.Provider.Polly
|
namespace Ocelot.Provider.Polly
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration;
|
using Configuration;
|
||||||
using DependencyInjection;
|
using DependencyInjection;
|
||||||
using Errors;
|
using Errors;
|
||||||
@ -12,6 +8,10 @@
|
|||||||
using Logging;
|
using Logging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Requester;
|
using Requester;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public static class OcelotBuilderExtensions
|
public static class OcelotBuilderExtensions
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@
|
|||||||
return new PollyCircuitBreakingDelegatingHandler(new PollyQoSProvider(reRoute, logger), logger);
|
return new PollyCircuitBreakingDelegatingHandler(new PollyQoSProvider(reRoute, logger), logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Services.AddSingleton((QosDelegatingHandlerDelegate) QosDelegatingHandlerDelegate);
|
builder.Services.AddSingleton((QosDelegatingHandlerDelegate)QosDelegatingHandlerDelegate);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Polly;
|
using Polly;
|
||||||
using Polly.CircuitBreaker;
|
using Polly.CircuitBreaker;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Provider.Polly
|
namespace Ocelot.Provider.Polly
|
||||||
{
|
{
|
||||||
@ -26,11 +26,11 @@ namespace Ocelot.Provider.Polly
|
|||||||
{
|
{
|
||||||
return await Policy
|
return await Policy
|
||||||
.WrapAsync(_qoSProvider.CircuitBreaker.Policies)
|
.WrapAsync(_qoSProvider.CircuitBreaker.Policies)
|
||||||
.ExecuteAsync(() => base.SendAsync(request,cancellationToken));
|
.ExecuteAsync(() => base.SendAsync(request, cancellationToken));
|
||||||
}
|
}
|
||||||
catch (BrokenCircuitException ex)
|
catch (BrokenCircuitException ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"Reached to allowed number of exceptions. Circuit is open",ex);
|
_logger.LogError($"Reached to allowed number of exceptions. Circuit is open", ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (HttpRequestException ex)
|
catch (HttpRequestException ex)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
namespace Ocelot.Provider.Polly
|
namespace Ocelot.Provider.Polly
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Net.Http;
|
|
||||||
using global::Polly;
|
using global::Polly;
|
||||||
using global::Polly.CircuitBreaker;
|
using global::Polly.CircuitBreaker;
|
||||||
using global::Polly.Timeout;
|
using global::Polly.Timeout;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
public class PollyQoSProvider
|
public class PollyQoSProvider
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Ocelot.Provider.Polly
|
namespace Ocelot.Provider.Polly
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using Errors;
|
using Errors;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class RequestTimedOutError : Error
|
public class RequestTimedOutError : Error
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System.Net.Http;
|
using Administration;
|
||||||
using Configuration;
|
|
||||||
using Configuration.Repository;
|
using Configuration.Repository;
|
||||||
using global::Rafty.Concensus.Peers;
|
using global::Rafty.Concensus.Peers;
|
||||||
using global::Rafty.Infrastructure;
|
using global::Rafty.Infrastructure;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Administration;
|
using System.Net.Http;
|
||||||
|
|
||||||
public class FilePeersProvider : IPeersProvider
|
public class FilePeersProvider : IPeersProvider
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System.Net.Http;
|
using Administration;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration;
|
using Configuration;
|
||||||
using global::Rafty.Concensus.Messages;
|
using global::Rafty.Concensus.Messages;
|
||||||
using global::Rafty.Concensus.Peers;
|
using global::Rafty.Concensus.Peers;
|
||||||
@ -11,7 +10,8 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Administration;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class HttpPeer : IPeer
|
public class HttpPeer : IPeer
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration.Setter;
|
using Configuration.Setter;
|
||||||
using global::Rafty.FiniteStateMachine;
|
using global::Rafty.FiniteStateMachine;
|
||||||
using global::Rafty.Log;
|
using global::Rafty.Log;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class OcelotFiniteStateMachine : IFiniteStateMachine
|
public class OcelotFiniteStateMachine : IFiniteStateMachine
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using global::Rafty.Concensus.Messages;
|
using global::Rafty.Concensus.Messages;
|
||||||
using global::Rafty.Concensus.Node;
|
using global::Rafty.Concensus.Node;
|
||||||
using global::Rafty.FiniteStateMachine;
|
using global::Rafty.FiniteStateMachine;
|
||||||
@ -11,6 +8,9 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("raft")]
|
[Route("raft")]
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Configuration.File;
|
using Configuration.File;
|
||||||
using Configuration.Setter;
|
using Configuration.Setter;
|
||||||
using global::Rafty.Concensus.Node;
|
using global::Rafty.Concensus.Node;
|
||||||
using global::Rafty.Infrastructure;
|
using global::Rafty.Infrastructure;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class RaftyFileConfigurationSetter : IFileConfigurationSetter
|
public class RaftyFileConfigurationSetter : IFileConfigurationSetter
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System.Threading.Tasks;
|
|
||||||
using global::Rafty.Concensus.Node;
|
using global::Rafty.Concensus.Node;
|
||||||
using global::Rafty.Infrastructure;
|
using global::Rafty.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Middleware;
|
using Middleware;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public static class RaftyMiddlewareConfigurationProvider
|
public static class RaftyMiddlewareConfigurationProvider
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using global::Rafty.Infrastructure;
|
using global::Rafty.Infrastructure;
|
||||||
using global::Rafty.Log;
|
using global::Rafty.Log;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class SqlLiteLog : ILog
|
public class SqlLiteLog : ILog
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
namespace Ocelot.Provider.Rafty
|
namespace Ocelot.Provider.Rafty
|
||||||
{
|
{
|
||||||
using Errors;
|
using Errors;
|
||||||
|
|
||||||
public class UnableToSaveAcceptCommand : Error
|
public class UnableToSaveAcceptCommand : Error
|
||||||
{
|
{
|
||||||
public UnableToSaveAcceptCommand(string message)
|
public UnableToSaveAcceptCommand(string message)
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
namespace Ocelot.Tracing.Butterfly
|
namespace Ocelot.Tracing.Butterfly
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using global::Butterfly.Client.AspNetCore;
|
using global::Butterfly.Client.AspNetCore;
|
||||||
using global::Butterfly.Client.Tracing;
|
using global::Butterfly.Client.Tracing;
|
||||||
using global::Butterfly.OpenTracing;
|
using global::Butterfly.OpenTracing;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class ButterflyTracer : DelegatingHandler, Logging.ITracer
|
public class ButterflyTracer : DelegatingHandler, Logging.ITracer
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Tracing.Butterfly
|
namespace Ocelot.Tracing.Butterfly
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using DependencyInjection;
|
using DependencyInjection;
|
||||||
using global::Butterfly.Client.AspNetCore;
|
using global::Butterfly.Client.AspNetCore;
|
||||||
using Logging;
|
using Logging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
|
||||||
public static class OcelotBuilderExtensions
|
public static class OcelotBuilderExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Errors;
|
|
||||||
using Ocelot.Infrastructure.Extensions;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Authentication.Middleware
|
namespace Ocelot.Authentication.Middleware
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
using System;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
|
using Ocelot.Responses;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
|
||||||
using Ocelot.Middleware;
|
|
||||||
using Ocelot.Responses;
|
|
||||||
using Ocelot.Values;
|
|
||||||
|
|
||||||
namespace Ocelot.Authorisation
|
namespace Ocelot.Authorisation
|
||||||
{
|
{
|
||||||
using Infrastructure.Claims.Parser;
|
using Infrastructure.Claims.Parser;
|
||||||
@ -26,7 +22,8 @@ namespace Ocelot.Authorisation
|
|||||||
ClaimsPrincipal claimsPrincipal,
|
ClaimsPrincipal claimsPrincipal,
|
||||||
Dictionary<string, string> routeClaimsRequirement,
|
Dictionary<string, string> routeClaimsRequirement,
|
||||||
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
|
List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
|
||||||
){
|
)
|
||||||
|
{
|
||||||
foreach (var required in routeClaimsRequirement)
|
foreach (var required in routeClaimsRequirement)
|
||||||
{
|
{
|
||||||
var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
|
var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
|
||||||
@ -62,15 +59,14 @@ namespace Ocelot.Authorisation
|
|||||||
if (matchingPlaceholders.Length == 0)
|
if (matchingPlaceholders.Length == 0)
|
||||||
{
|
{
|
||||||
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
|
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
|
||||||
$"config error: requires variable claim value: {variableName} placeholders does not contain that variable: {string.Join(", ", urlPathPlaceholderNameAndValues.Select(p=>p.Name))}"));
|
$"config error: requires variable claim value: {variableName} placeholders does not contain that variable: {string.Join(", ", urlPathPlaceholderNameAndValues.Select(p => p.Name))}"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
|
return new ErrorResponse<bool>(new ClaimValueNotAuthorisedError(
|
||||||
$"config error: requires variable claim value: {required.Value} but placeholders are ambiguous: {string.Join(", ", urlPathPlaceholderNameAndValues.Where(p=>p.Name.Equals(variableName)).Select(p => p.Value))}"));
|
$"config error: requires variable claim value: {required.Value} but placeholders are ambiguous: {string.Join(", ", urlPathPlaceholderNameAndValues.Where(p => p.Name.Equals(variableName)).Select(p => p.Value))}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using System.Security.Claims;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
|
|
||||||
using Ocelot.Configuration;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
using Ocelot.Values;
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace Ocelot.Authorisation
|
namespace Ocelot.Authorisation
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Security.Claims;
|
using Ocelot.Responses;
|
||||||
using Ocelot.Responses;
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace Ocelot.Authorisation
|
namespace Ocelot.Authorisation
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
namespace Ocelot.Authorisation.Middleware
|
namespace Ocelot.Authorisation.Middleware
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Errors;
|
|
||||||
using Ocelot.Middleware;
|
|
||||||
using Logging;
|
|
||||||
using Responses;
|
|
||||||
using Configuration;
|
using Configuration;
|
||||||
|
using Logging;
|
||||||
|
using Ocelot.Middleware;
|
||||||
|
using Responses;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class AuthorisationMiddleware : OcelotMiddleware
|
public class AuthorisationMiddleware : OcelotMiddleware
|
||||||
{
|
{
|
||||||
@ -18,7 +16,7 @@
|
|||||||
IClaimsAuthoriser claimsAuthoriser,
|
IClaimsAuthoriser claimsAuthoriser,
|
||||||
IScopesAuthoriser scopesAuthoriser,
|
IScopesAuthoriser scopesAuthoriser,
|
||||||
IOcelotLoggerFactory loggerFactory)
|
IOcelotLoggerFactory loggerFactory)
|
||||||
:base(loggerFactory.CreateLogger<AuthorisationMiddleware>())
|
: base(loggerFactory.CreateLogger<AuthorisationMiddleware>())
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_claimsAuthoriser = claimsAuthoriser;
|
_claimsAuthoriser = claimsAuthoriser;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace Ocelot.Authorisation
|
namespace Ocelot.Authorisation
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
using System.Text;
|
using Ocelot.Middleware;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ocelot.Middleware;
|
|
||||||
|
|
||||||
namespace Ocelot.Cache {
|
namespace Ocelot.Cache
|
||||||
public class CacheKeyGenerator : ICacheKeyGenerator {
|
{
|
||||||
public string GenerateRequestCacheKey(DownstreamContext context) {
|
public class CacheKeyGenerator : ICacheKeyGenerator
|
||||||
|
{
|
||||||
|
public string GenerateRequestCacheKey(DownstreamContext context)
|
||||||
|
{
|
||||||
string hashedContent = null;
|
string hashedContent = null;
|
||||||
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
|
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
|
||||||
if (context.DownstreamRequest.Content != null) {
|
if (context.DownstreamRequest.Content != null)
|
||||||
|
{
|
||||||
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content.ReadAsStringAsync()).Result;
|
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content.ReadAsStringAsync()).Result;
|
||||||
downStreamUrlKeyBuilder.Append(requestContentString);
|
downStreamUrlKeyBuilder.Append(requestContentString);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
class CacheObject<T>
|
internal class CacheObject<T>
|
||||||
{
|
{
|
||||||
public CacheObject(T value, DateTime expires)
|
public CacheObject(T value, DateTime expires)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
namespace Ocelot.Cache {
|
namespace Ocelot.Cache
|
||||||
public interface ICacheKeyGenerator {
|
{
|
||||||
|
public interface ICacheKeyGenerator
|
||||||
|
{
|
||||||
string GenerateRequestCacheKey(DownstreamContext context);
|
string GenerateRequestCacheKey(DownstreamContext context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,11 @@ namespace Ocelot.Cache
|
|||||||
public interface IOcelotCache<T>
|
public interface IOcelotCache<T>
|
||||||
{
|
{
|
||||||
void Add(string key, T value, TimeSpan ttl, string region);
|
void Add(string key, T value, TimeSpan ttl, string region);
|
||||||
|
|
||||||
T Get(string key, string region);
|
T Get(string key, string region);
|
||||||
|
|
||||||
void ClearRegion(string region);
|
void ClearRegion(string region);
|
||||||
|
|
||||||
void AddAndDelete(string key, T value, TimeSpan ttl, string region);
|
void AddAndDelete(string key, T value, TimeSpan ttl, string region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_regions.Add(region, new List<string>{ key });
|
_regions.Add(region, new List<string> { key });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ocelot.Cache {
|
namespace Ocelot.Cache
|
||||||
public static class MD5Helper {
|
{
|
||||||
public static string GenerateMd5(byte[] contentBytes) {
|
public static class MD5Helper
|
||||||
|
{
|
||||||
|
public static string GenerateMd5(byte[] contentBytes)
|
||||||
|
{
|
||||||
MD5 md5 = MD5.Create();
|
MD5 md5 = MD5.Create();
|
||||||
byte[] hash = md5.ComputeHash(contentBytes);
|
byte[] hash = md5.ComputeHash(contentBytes);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < hash.Length; i++) {
|
for (int i = 0; i < hash.Length; i++)
|
||||||
|
{
|
||||||
sb.Append(hash[i].ToString("X2"));
|
sb.Append(hash[i].ToString("X2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateMd5(string contentString) {
|
public static string GenerateMd5(string contentString)
|
||||||
|
{
|
||||||
byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
|
byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
|
||||||
return GenerateMd5(contentBytes);
|
return GenerateMd5(contentBytes);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
namespace Ocelot.Cache.Middleware
|
namespace Ocelot.Cache.Middleware
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class OutputCacheMiddleware : OcelotMiddleware
|
public class OutputCacheMiddleware : OcelotMiddleware
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@
|
|||||||
IOcelotLoggerFactory loggerFactory,
|
IOcelotLoggerFactory loggerFactory,
|
||||||
IOcelotCache<CachedResponse> outputCache,
|
IOcelotCache<CachedResponse> outputCache,
|
||||||
ICacheKeyGenerator cacheGeneratot)
|
ICacheKeyGenerator cacheGeneratot)
|
||||||
:base(loggerFactory.CreateLogger<OutputCacheMiddleware>())
|
: base(loggerFactory.CreateLogger<OutputCacheMiddleware>())
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_outputCache = outputCache;
|
_outputCache = outputCache;
|
||||||
@ -77,10 +77,12 @@
|
|||||||
context.DownstreamResponse = response;
|
context.DownstreamResponse = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GenerateRequestCacheKey(DownstreamContext context) {
|
private string GenerateRequestCacheKey(DownstreamContext context)
|
||||||
|
{
|
||||||
string hashedContent = null;
|
string hashedContent = null;
|
||||||
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
|
StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
|
||||||
if(context.DownstreamRequest.Content != null) {
|
if (context.DownstreamRequest.Content != null)
|
||||||
|
{
|
||||||
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content?.ReadAsStringAsync()).Result;
|
string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content?.ReadAsStringAsync()).Result;
|
||||||
downStreamUrlKeyBuilder.Append(requestContentString);
|
downStreamUrlKeyBuilder.Append(requestContentString);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Linq;
|
|
||||||
using Ocelot.Configuration;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ocelot.Cache
|
namespace Ocelot.Cache
|
||||||
{
|
{
|
||||||
@ -8,7 +7,7 @@ namespace Ocelot.Cache
|
|||||||
{
|
{
|
||||||
public string Create(FileReRoute reRoute)
|
public string Create(FileReRoute reRoute)
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
|
if (!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
|
||||||
{
|
{
|
||||||
return reRoute?.FileCacheOptions?.Region;
|
return reRoute?.FileCacheOptions?.Region;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Infrastructure.Claims.Parser;
|
using Ocelot.Infrastructure.Claims.Parser;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace Ocelot.Claims
|
namespace Ocelot.Claims
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Claims
|
namespace Ocelot.Claims
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using System.Linq;
|
using Ocelot.Logging;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.Infrastructure.RequestData;
|
|
||||||
using Ocelot.Logging;
|
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Claims.Middleware
|
namespace Ocelot.Claims.Middleware
|
||||||
{
|
{
|
||||||
@ -16,7 +13,7 @@ namespace Ocelot.Claims.Middleware
|
|||||||
public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
|
public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
|
||||||
IOcelotLoggerFactory loggerFactory,
|
IOcelotLoggerFactory loggerFactory,
|
||||||
IAddClaimsToRequest addClaimsToRequest)
|
IAddClaimsToRequest addClaimsToRequest)
|
||||||
:base(loggerFactory.CreateLogger<ClaimsToClaimsMiddleware>())
|
: base(loggerFactory.CreateLogger<ClaimsToClaimsMiddleware>())
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_addClaimsToRequest = addClaimsToRequest;
|
_addClaimsToRequest = addClaimsToRequest;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using Ocelot.Values;
|
|
||||||
using System.Linq;
|
|
||||||
using Ocelot.Configuration.Creator;
|
using Ocelot.Configuration.Creator;
|
||||||
|
using Ocelot.Values;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Builder
|
namespace Ocelot.Configuration.Builder
|
||||||
{
|
{
|
||||||
@ -39,6 +39,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
private List<AddHeader> _addHeadersToUpstream;
|
private List<AddHeader> _addHeadersToUpstream;
|
||||||
private bool _dangerousAcceptAnyServerCertificateValidator;
|
private bool _dangerousAcceptAnyServerCertificateValidator;
|
||||||
private SecurityOptions _securityOptions;
|
private SecurityOptions _securityOptions;
|
||||||
|
|
||||||
public DownstreamReRouteBuilder()
|
public DownstreamReRouteBuilder()
|
||||||
{
|
{
|
||||||
_downstreamAddresses = new List<DownstreamHostAndPort>();
|
_downstreamAddresses = new List<DownstreamHostAndPort>();
|
||||||
@ -55,7 +56,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
|
|
||||||
public DownstreamReRouteBuilder WithLoadBalancerOptions(LoadBalancerOptions loadBalancerOptions)
|
public DownstreamReRouteBuilder WithLoadBalancerOptions(LoadBalancerOptions loadBalancerOptions)
|
||||||
{
|
{
|
||||||
_loadBalancerOptions = loadBalancerOptions;
|
_loadBalancerOptions = loadBalancerOptions;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Configuration.Builder
|
namespace Ocelot.Configuration.Builder
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using Ocelot.Values;
|
|
||||||
using System.Linq;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using Ocelot.Values;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
public class ReRouteBuilder
|
public class ReRouteBuilder
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Builder;
|
using Builder;
|
||||||
using File;
|
using File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public class AggregatesCreator : IAggregatesCreator
|
public class AggregatesCreator : IAggregatesCreator
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.Parser;
|
using Ocelot.Configuration.Parser;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
_claimToThingConfigParser = claimToThingConfigurationParser;
|
_claimToThingConfigParser = claimToThingConfigurationParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClaimToThing> Create(Dictionary<string,string> inputToBeParsed)
|
public List<ClaimToThing> Create(Dictionary<string, string> inputToBeParsed)
|
||||||
{
|
{
|
||||||
var claimsToThings = new List<ClaimToThing>();
|
var claimsToThings = new List<ClaimToThing>();
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
using DependencyInjection;
|
||||||
|
using File;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using File;
|
|
||||||
using DependencyInjection;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
public class ConfigurationCreator : IConfigurationCreator
|
public class ConfigurationCreator : IConfigurationCreator
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
using Ocelot.Configuration.File;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Ocelot.Configuration.File;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Builder;
|
using Builder;
|
||||||
using File;
|
using File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public class DynamicsCreator : IDynamicsCreator
|
public class DynamicsCreator : IDynamicsCreator
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
using File;
|
||||||
|
using Responses;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using File;
|
|
||||||
using Validator;
|
using Validator;
|
||||||
using Responses;
|
|
||||||
|
|
||||||
public class FileInternalConfigurationCreator : IInternalConfigurationCreator
|
public class FileInternalConfigurationCreator : IInternalConfigurationCreator
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Infrastructure;
|
using Ocelot.Infrastructure;
|
||||||
using Ocelot.Infrastructure.Extensions;
|
using Ocelot.Infrastructure.Extensions;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Middleware;
|
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
@ -25,7 +23,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
var upstream = new List<HeaderFindAndReplace>();
|
var upstream = new List<HeaderFindAndReplace>();
|
||||||
var addHeadersToUpstream = new List<AddHeader>();
|
var addHeadersToUpstream = new List<AddHeader>();
|
||||||
|
|
||||||
foreach(var input in fileReRoute.UpstreamHeaderTransform)
|
foreach (var input in fileReRoute.UpstreamHeaderTransform)
|
||||||
{
|
{
|
||||||
if (input.Value.Contains(","))
|
if (input.Value.Contains(","))
|
||||||
{
|
{
|
||||||
@ -48,12 +46,12 @@ namespace Ocelot.Configuration.Creator
|
|||||||
var downstream = new List<HeaderFindAndReplace>();
|
var downstream = new List<HeaderFindAndReplace>();
|
||||||
var addHeadersToDownstream = new List<AddHeader>();
|
var addHeadersToDownstream = new List<AddHeader>();
|
||||||
|
|
||||||
foreach(var input in fileReRoute.DownstreamHeaderTransform)
|
foreach (var input in fileReRoute.DownstreamHeaderTransform)
|
||||||
{
|
{
|
||||||
if(input.Value.Contains(","))
|
if (input.Value.Contains(","))
|
||||||
{
|
{
|
||||||
var hAndr = Map(input);
|
var hAndr = Map(input);
|
||||||
if(!hAndr.IsError)
|
if (!hAndr.IsError)
|
||||||
{
|
{
|
||||||
downstream.Add(hAndr.Data);
|
downstream.Add(hAndr.Data);
|
||||||
}
|
}
|
||||||
@ -71,14 +69,14 @@ namespace Ocelot.Configuration.Creator
|
|||||||
return new HeaderTransformations(upstream, downstream, addHeadersToDownstream, addHeadersToUpstream);
|
return new HeaderTransformations(upstream, downstream, addHeadersToDownstream, addHeadersToUpstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response<HeaderFindAndReplace> Map(KeyValuePair<string,string> input)
|
private Response<HeaderFindAndReplace> Map(KeyValuePair<string, string> input)
|
||||||
{
|
{
|
||||||
var findAndReplace = input.Value.Split(",");
|
var findAndReplace = input.Value.Split(",");
|
||||||
|
|
||||||
var replace = findAndReplace[1].TrimStart();
|
var replace = findAndReplace[1].TrimStart();
|
||||||
|
|
||||||
var startOfPlaceholder = replace.IndexOf("{");
|
var startOfPlaceholder = replace.IndexOf("{");
|
||||||
if(startOfPlaceholder > -1)
|
if (startOfPlaceholder > -1)
|
||||||
{
|
{
|
||||||
var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
|
var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
|
|
||||||
var value = _placeholders.Get(placeholder);
|
var value = _placeholders.Get(placeholder);
|
||||||
|
|
||||||
if(value.IsError)
|
if (value.IsError)
|
||||||
{
|
{
|
||||||
return new ErrorResponse<HeaderFindAndReplace>(value.Errors);
|
return new ErrorResponse<HeaderFindAndReplace>(value.Errors);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using Logging;
|
using Logging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator
|
public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
public HttpHandlerOptions Create(FileHttpHandlerOptions options)
|
public HttpHandlerOptions Create(FileHttpHandlerOptions options)
|
||||||
{
|
{
|
||||||
var useTracing = _tracer!= null && options.UseTracing;
|
var useTracing = _tracer != null && options.UseTracing;
|
||||||
|
|
||||||
return new HttpHandlerOptions(options.AllowAutoRedirect,
|
return new HttpHandlerOptions(options.AllowAutoRedirect,
|
||||||
options.UseCookieContainer, useTracing, options.UseProxy);
|
options.UseCookieContainer, useTracing, options.UseProxy);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
|
@ -4,6 +4,6 @@ namespace Ocelot.Configuration.Creator
|
|||||||
{
|
{
|
||||||
public interface IClaimsToThingCreator
|
public interface IClaimsToThingCreator
|
||||||
{
|
{
|
||||||
List<ClaimToThing> Create(Dictionary<string,string> thingsBeingAdded);
|
List<ClaimToThing> Create(Dictionary<string, string> thingsBeingAdded);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
public interface IQoSOptionsCreator
|
public interface IQoSOptionsCreator
|
||||||
{
|
{
|
||||||
QoSOptions Create(FileQoSOptions options);
|
QoSOptions Create(FileQoSOptions options);
|
||||||
|
|
||||||
QoSOptions Create(FileQoSOptions options, string pathTemplate, List<string> httpMethods);
|
QoSOptions Create(FileQoSOptions options, string pathTemplate, List<string> httpMethods);
|
||||||
|
|
||||||
QoSOptions Create(QoSOptions options, string pathTemplate, List<string> httpMethods);
|
QoSOptions Create(QoSOptions options, string pathTemplate, List<string> httpMethods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Linq;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.LoadBalancer.LoadBalancers;
|
using Ocelot.LoadBalancer.LoadBalancers;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
using Builder;
|
||||||
|
using Cache;
|
||||||
|
using File;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Cache;
|
|
||||||
using Builder;
|
|
||||||
using File;
|
|
||||||
|
|
||||||
public class ReRoutesCreator : IReRoutesCreator
|
public class ReRoutesCreator : IReRoutesCreator
|
||||||
{
|
{
|
||||||
|
@ -8,11 +8,11 @@ namespace Ocelot.Configuration.Creator
|
|||||||
{
|
{
|
||||||
var reRouteId = !string.IsNullOrEmpty(fileReRoute.RequestIdKey);
|
var reRouteId = !string.IsNullOrEmpty(fileReRoute.RequestIdKey);
|
||||||
|
|
||||||
var requestIdKey = reRouteId
|
var requestIdKey = reRouteId
|
||||||
? fileReRoute.RequestIdKey
|
? fileReRoute.RequestIdKey
|
||||||
: globalConfiguration.RequestIdKey;
|
: globalConfiguration.RequestIdKey;
|
||||||
|
|
||||||
return requestIdKey;
|
return requestIdKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,4 @@
|
|||||||
using System;
|
using Ocelot.Configuration.File;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Ocelot.Configuration.File;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Values;
|
using Ocelot.Values;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
placeholders.Add(placeHolderName);
|
placeholders.Add(placeHolderName);
|
||||||
|
|
||||||
//hack to handle /{url} case
|
//hack to handle /{url} case
|
||||||
if(ForwardSlashAndOnePlaceHolder(upstreamTemplate, placeholders, postitionOfPlaceHolderClosingBracket))
|
if (ForwardSlashAndOnePlaceHolder(upstreamTemplate, placeholders, postitionOfPlaceHolderClosingBracket))
|
||||||
{
|
{
|
||||||
return new UpstreamPathTemplate(RegExForwardSlashAndOnePlaceHolder, 0, false, reRoute.UpstreamPathTemplate);
|
return new UpstreamPathTemplate(RegExForwardSlashAndOnePlaceHolder, 0, false, reRoute.UpstreamPathTemplate);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
{
|
{
|
||||||
var indexOfPlaceholder = upstreamTemplate.IndexOf(placeholders[i]);
|
var indexOfPlaceholder = upstreamTemplate.IndexOf(placeholders[i]);
|
||||||
var indexOfNextForwardSlash = upstreamTemplate.IndexOf("/", indexOfPlaceholder);
|
var indexOfNextForwardSlash = upstreamTemplate.IndexOf("/", indexOfPlaceholder);
|
||||||
if(indexOfNextForwardSlash < indexOfPlaceholder || (containsQueryString && upstreamTemplate.IndexOf("?") < upstreamTemplate.IndexOf(placeholders[i])))
|
if (indexOfNextForwardSlash < indexOfPlaceholder || (containsQueryString && upstreamTemplate.IndexOf("?") < upstreamTemplate.IndexOf(placeholders[i])))
|
||||||
{
|
{
|
||||||
upstreamTemplate = upstreamTemplate.Replace(placeholders[i], RegExMatchOneOrMoreOfEverything);
|
upstreamTemplate = upstreamTemplate.Replace(placeholders[i], RegExMatchOneOrMoreOfEverything);
|
||||||
}
|
}
|
||||||
@ -63,9 +63,9 @@ namespace Ocelot.Configuration.Creator
|
|||||||
return new UpstreamPathTemplate(RegExForwardSlashOnly, reRoute.Priority, containsQueryString, reRoute.UpstreamPathTemplate);
|
return new UpstreamPathTemplate(RegExForwardSlashOnly, reRoute.Priority, containsQueryString, reRoute.UpstreamPathTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(upstreamTemplate.EndsWith("/"))
|
if (upstreamTemplate.EndsWith("/"))
|
||||||
{
|
{
|
||||||
upstreamTemplate = upstreamTemplate.Remove(upstreamTemplate.Length -1, 1) + "(/|)";
|
upstreamTemplate = upstreamTemplate.Remove(upstreamTemplate.Length - 1, 1) + "(/|)";
|
||||||
}
|
}
|
||||||
|
|
||||||
var route = reRoute.ReRouteIsCaseSensitive
|
var route = reRoute.ReRouteIsCaseSensitive
|
||||||
@ -77,7 +77,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
|
|
||||||
private bool ForwardSlashAndOnePlaceHolder(string upstreamTemplate, List<string> placeholders, int postitionOfPlaceHolderClosingBracket)
|
private bool ForwardSlashAndOnePlaceHolder(string upstreamTemplate, List<string> placeholders, int postitionOfPlaceHolderClosingBracket)
|
||||||
{
|
{
|
||||||
if(upstreamTemplate.Substring(0, 2) == "/{" && placeholders.Count == 1 && upstreamTemplate.Length == postitionOfPlaceHolderClosingBracket + 1)
|
if (upstreamTemplate.Substring(0, 2) == "/{" && placeholders.Count == 1 && upstreamTemplate.Length == postitionOfPlaceHolderClosingBracket + 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Ocelot.Configuration
|
namespace Ocelot.Configuration
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using Creator;
|
using Creator;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Values;
|
using Values;
|
||||||
|
|
||||||
public class DownstreamReRoute
|
public class DownstreamReRoute
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace Ocelot.Configuration.File
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.File
|
|
||||||
{
|
{
|
||||||
public class AggregateReRouteConfig
|
public class AggregateReRouteConfig
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,9 @@ namespace Ocelot.Configuration.File
|
|||||||
{
|
{
|
||||||
public class FileAggregateReRoute : IReRoute
|
public class FileAggregateReRoute : IReRoute
|
||||||
{
|
{
|
||||||
public List<string> ReRouteKeys { get;set; }
|
public List<string> ReRouteKeys { get; set; }
|
||||||
public List<AggregateReRouteConfig> ReRouteKeysConfig { get;set; }
|
public List<AggregateReRouteConfig> ReRouteKeysConfig { get; set; }
|
||||||
public string UpstreamPathTemplate { get;set; }
|
public string UpstreamPathTemplate { get; set; }
|
||||||
public string UpstreamHost { get; set; }
|
public string UpstreamHost { get; set; }
|
||||||
public bool ReRouteIsCaseSensitive { get; set; }
|
public bool ReRouteIsCaseSensitive { get; set; }
|
||||||
public string Aggregator { get; set; }
|
public string Aggregator { get; set; }
|
||||||
@ -14,9 +14,9 @@ namespace Ocelot.Configuration.File
|
|||||||
// Only supports GET..are you crazy!! POST, PUT WOULD BE CRAZY!! :)
|
// Only supports GET..are you crazy!! POST, PUT WOULD BE CRAZY!! :)
|
||||||
public List<string> UpstreamHttpMethod
|
public List<string> UpstreamHttpMethod
|
||||||
{
|
{
|
||||||
get { return new List<string> {"Get"}; }
|
get { return new List<string> { "Get" }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Priority {get;set;} = 1;
|
public int Priority { get; set; } = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using Ocelot.Infrastructure.Extensions;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Ocelot.Infrastructure.Extensions;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.File
|
namespace Ocelot.Configuration.File
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ namespace Ocelot.Configuration.File
|
|||||||
AllowedScopes = new List<string>();
|
AllowedScopes = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AuthenticationProviderKey {get; set;}
|
public string AuthenticationProviderKey { get; set; }
|
||||||
public List<string> AllowedScopes { get; set; }
|
public List<string> AllowedScopes { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
public class FileCacheOptions
|
public class FileCacheOptions
|
||||||
{
|
{
|
||||||
public int TtlSeconds { get; set; }
|
public int TtlSeconds { get; set; }
|
||||||
public string Region {get; set;}
|
public string Region { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ namespace Ocelot.Configuration.File
|
|||||||
public List<FileDynamicReRoute> DynamicReRoutes { get; set; }
|
public List<FileDynamicReRoute> DynamicReRoutes { get; set; }
|
||||||
|
|
||||||
// Seperate field for aggregates because this let's you re-use ReRoutes in multiple Aggregates
|
// Seperate field for aggregates because this let's you re-use ReRoutes in multiple Aggregates
|
||||||
public List<FileAggregateReRoute> Aggregates { get;set; }
|
public List<FileAggregateReRoute> Aggregates { get; set; }
|
||||||
|
|
||||||
public FileGlobalConfiguration GlobalConfiguration { get; set; }
|
public FileGlobalConfiguration GlobalConfiguration { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
public string RequestIdKey { get; set; }
|
public string RequestIdKey { get; set; }
|
||||||
|
|
||||||
public FileServiceDiscoveryProvider ServiceDiscoveryProvider { get;set; }
|
public FileServiceDiscoveryProvider ServiceDiscoveryProvider { get; set; }
|
||||||
|
|
||||||
public FileRateLimitOptions RateLimitOptions { get; set; }
|
public FileRateLimitOptions RateLimitOptions { get; set; }
|
||||||
|
|
||||||
public FileQoSOptions QoSOptions { get; set; }
|
public FileQoSOptions QoSOptions { get; set; }
|
||||||
|
|
||||||
public string BaseUrl { get ;set; }
|
public string BaseUrl { get; set; }
|
||||||
|
|
||||||
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
|
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ namespace Ocelot.Configuration.File
|
|||||||
{
|
{
|
||||||
public class FileHostAndPort
|
public class FileHostAndPort
|
||||||
{
|
{
|
||||||
public string Host {get;set;}
|
public string Host { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
namespace Ocelot.Configuration.File
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.File
|
|
||||||
{
|
{
|
||||||
public class FileRateLimitOptions
|
public class FileRateLimitOptions
|
||||||
{
|
{
|
||||||
@ -32,6 +27,6 @@ namespace Ocelot.Configuration.File
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the HTTP Status code returned when rate limiting occurs, by default value is set to 429 (Too Many Requests)
|
/// Gets or sets the HTTP Status code returned when rate limiting occurs, by default value is set to 429 (Too Many Requests)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int HttpStatusCode { get; set; } = 429;
|
public int HttpStatusCode { get; set; } = 429;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using System;
|
using Ocelot.Infrastructure.Extensions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Ocelot.Infrastructure.Extensions;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.File
|
namespace Ocelot.Configuration.File
|
||||||
{
|
{
|
||||||
|
@ -38,17 +38,17 @@ namespace Ocelot.Configuration.File
|
|||||||
public FileCacheOptions FileCacheOptions { get; set; }
|
public FileCacheOptions FileCacheOptions { get; set; }
|
||||||
public bool ReRouteIsCaseSensitive { get; set; }
|
public bool ReRouteIsCaseSensitive { get; set; }
|
||||||
public string ServiceName { get; set; }
|
public string ServiceName { get; set; }
|
||||||
public string DownstreamScheme {get;set;}
|
public string DownstreamScheme { get; set; }
|
||||||
public FileQoSOptions QoSOptions { get; set; }
|
public FileQoSOptions QoSOptions { get; set; }
|
||||||
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
|
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
|
||||||
public FileRateLimitRule RateLimitOptions { get; set; }
|
public FileRateLimitRule RateLimitOptions { get; set; }
|
||||||
public FileAuthenticationOptions AuthenticationOptions { get; set; }
|
public FileAuthenticationOptions AuthenticationOptions { get; set; }
|
||||||
public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
|
public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
|
||||||
public List<FileHostAndPort> DownstreamHostAndPorts {get;set;}
|
public List<FileHostAndPort> DownstreamHostAndPorts { get; set; }
|
||||||
public string UpstreamHost { get; set; }
|
public string UpstreamHost { get; set; }
|
||||||
public string Key { get;set; }
|
public string Key { get; set; }
|
||||||
public List<string> DelegatingHandlers {get;set;}
|
public List<string> DelegatingHandlers { get; set; }
|
||||||
public int Priority { get;set; }
|
public int Priority { get; set; }
|
||||||
public int Timeout { get; set; }
|
public int Timeout { get; set; }
|
||||||
public bool DangerousAcceptAnyServerCertificateValidator { get; set; }
|
public bool DangerousAcceptAnyServerCertificateValidator { get; set; }
|
||||||
public FileSecurityOptions SecurityOptions { get; set; }
|
public FileSecurityOptions SecurityOptions { get; set; }
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.File
|
namespace Ocelot.Configuration.File
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ namespace Ocelot.Configuration.File
|
|||||||
{
|
{
|
||||||
public class FileServiceDiscoveryProvider
|
public class FileServiceDiscoveryProvider
|
||||||
{
|
{
|
||||||
public string Host {get;set;}
|
public string Host { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
{
|
{
|
||||||
string UpstreamPathTemplate { get; set; }
|
string UpstreamPathTemplate { get; set; }
|
||||||
bool ReRouteIsCaseSensitive { get; set; }
|
bool ReRouteIsCaseSensitive { get; set; }
|
||||||
int Priority {get;set;}
|
int Priority { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Configuration.Setter;
|
using Ocelot.Configuration.Setter;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
namespace Ocelot.Configuration
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace Ocelot.Configuration
|
|||||||
{
|
{
|
||||||
var response = await _repo.Get();
|
var response = await _repo.Get();
|
||||||
|
|
||||||
if(response.IsError)
|
if (response.IsError)
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult(response.Errors);
|
return new BadRequestObjectResult(response.Errors);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ namespace Ocelot.Configuration
|
|||||||
|
|
||||||
return new OkObjectResult(fileConfiguration);
|
return new OkObjectResult(fileConfiguration);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult($"{e.Message}:{e.StackTrace}");
|
return new BadRequestObjectResult($"{e.Message}:{e.StackTrace}");
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,11 @@ namespace Ocelot.Configuration
|
|||||||
Index = index;
|
Index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Key {get;}
|
public string Key { get; }
|
||||||
public string Find {get;}
|
public string Find { get; }
|
||||||
public string Replace {get;}
|
public string Replace { get; }
|
||||||
|
|
||||||
// only index 0 for now..
|
// only index 0 for now..
|
||||||
public int Index {get;}
|
public int Index { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,11 +6,11 @@ namespace Ocelot.Configuration
|
|||||||
{
|
{
|
||||||
List<ReRoute> ReRoutes { get; }
|
List<ReRoute> ReRoutes { get; }
|
||||||
|
|
||||||
string AdministrationPath {get;}
|
string AdministrationPath { get; }
|
||||||
|
|
||||||
ServiceProviderConfiguration ServiceProviderConfiguration {get;}
|
ServiceProviderConfiguration ServiceProviderConfiguration { get; }
|
||||||
|
|
||||||
string RequestId {get;}
|
string RequestId { get; }
|
||||||
|
|
||||||
LoadBalancerOptions LoadBalancerOptions { get; }
|
LoadBalancerOptions LoadBalancerOptions { get; }
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ namespace Ocelot.Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ReRoute> ReRoutes { get; }
|
public List<ReRoute> ReRoutes { get; }
|
||||||
public string AdministrationPath {get;}
|
public string AdministrationPath { get; }
|
||||||
public ServiceProviderConfiguration ServiceProviderConfiguration {get;}
|
public ServiceProviderConfiguration ServiceProviderConfiguration { get; }
|
||||||
public string RequestId {get;}
|
public string RequestId { get; }
|
||||||
public LoadBalancerOptions LoadBalancerOptions { get; }
|
public LoadBalancerOptions LoadBalancerOptions { get; }
|
||||||
public string DownstreamScheme { get; }
|
public string DownstreamScheme { get; }
|
||||||
public QoSOptions QoSOptions { get; }
|
public QoSOptions QoSOptions { get; }
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using Ocelot.Responses;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Ocelot.Errors;
|
|
||||||
using Ocelot.Responses;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Parser
|
namespace Ocelot.Configuration.Parser
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Ocelot.Errors;
|
||||||
using Ocelot.Errors;
|
using System;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Parser
|
namespace Ocelot.Configuration.Parser
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
namespace Ocelot.Configuration
|
||||||
{
|
{
|
||||||
@ -9,12 +7,12 @@ namespace Ocelot.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RateLimitOptions
|
public class RateLimitOptions
|
||||||
{
|
{
|
||||||
public RateLimitOptions(bool enbleRateLimiting, string clientIdHeader, List<string> clientWhitelist,bool disableRateLimitHeaders,
|
public RateLimitOptions(bool enbleRateLimiting, string clientIdHeader, List<string> clientWhitelist, bool disableRateLimitHeaders,
|
||||||
string quotaExceededMessage, string rateLimitCounterPrefix, RateLimitRule rateLimitRule, int httpStatusCode)
|
string quotaExceededMessage, string rateLimitCounterPrefix, RateLimitRule rateLimitRule, int httpStatusCode)
|
||||||
{
|
{
|
||||||
EnableRateLimiting = enbleRateLimiting;
|
EnableRateLimiting = enbleRateLimiting;
|
||||||
ClientIdHeader = clientIdHeader;
|
ClientIdHeader = clientIdHeader;
|
||||||
ClientWhitelist = clientWhitelist?? new List<string>();
|
ClientWhitelist = clientWhitelist ?? new List<string>();
|
||||||
DisableRateLimitHeaders = disableRateLimitHeaders;
|
DisableRateLimitHeaders = disableRateLimitHeaders;
|
||||||
QuotaExceededMessage = quotaExceededMessage;
|
QuotaExceededMessage = quotaExceededMessage;
|
||||||
RateLimitCounterPrefix = rateLimitCounterPrefix;
|
RateLimitCounterPrefix = rateLimitCounterPrefix;
|
||||||
@ -22,7 +20,7 @@ namespace Ocelot.Configuration
|
|||||||
HttpStatusCode = httpStatusCode;
|
HttpStatusCode = httpStatusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RateLimitRule RateLimitRule { get; private set; }
|
public RateLimitRule RateLimitRule { get; private set; }
|
||||||
|
|
||||||
public List<string> ClientWhitelist { get; private set; }
|
public List<string> ClientWhitelist { get; private set; }
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace Ocelot.Configuration
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
|
||||||
{
|
{
|
||||||
public class RateLimitRule
|
public class RateLimitRule
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Ocelot.Configuration
|
namespace Ocelot.Configuration
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Values;
|
using Ocelot.Values;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
public class ReRoute
|
public class ReRoute
|
||||||
{
|
{
|
||||||
@ -27,6 +27,6 @@
|
|||||||
public string UpstreamHost { get; private set; }
|
public string UpstreamHost { get; private set; }
|
||||||
public List<DownstreamReRoute> DownstreamReRoute { get; private set; }
|
public List<DownstreamReRoute> DownstreamReRoute { get; private set; }
|
||||||
public List<AggregateReRouteConfig> DownstreamReRouteConfig { get; private set; }
|
public List<AggregateReRouteConfig> DownstreamReRouteConfig { get; private set; }
|
||||||
public string Aggregator {get; private set;}
|
public string Aggregator { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,40 @@
|
|||||||
using System.Threading.Tasks;
|
using Ocelot.Responses;
|
||||||
using Ocelot.Responses;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Repository {
|
namespace Ocelot.Configuration.Repository
|
||||||
public class ConsulFileConfigurationPollerOption : IFileConfigurationPollerOptions {
|
{
|
||||||
|
public class ConsulFileConfigurationPollerOption : IFileConfigurationPollerOptions
|
||||||
|
{
|
||||||
private readonly IInternalConfigurationRepository _internalConfigRepo;
|
private readonly IInternalConfigurationRepository _internalConfigRepo;
|
||||||
private readonly IFileConfigurationRepository _fileConfigurationRepository;
|
private readonly IFileConfigurationRepository _fileConfigurationRepository;
|
||||||
|
|
||||||
public ConsulFileConfigurationPollerOption(IInternalConfigurationRepository internalConfigurationRepository,
|
public ConsulFileConfigurationPollerOption(IInternalConfigurationRepository internalConfigurationRepository,
|
||||||
IFileConfigurationRepository fileConfigurationRepository) {
|
IFileConfigurationRepository fileConfigurationRepository)
|
||||||
|
{
|
||||||
_internalConfigRepo = internalConfigurationRepository;
|
_internalConfigRepo = internalConfigurationRepository;
|
||||||
_fileConfigurationRepository = fileConfigurationRepository;
|
_fileConfigurationRepository = fileConfigurationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Delay => GetDelay();
|
public int Delay => GetDelay();
|
||||||
|
|
||||||
private int GetDelay() {
|
private int GetDelay()
|
||||||
|
{
|
||||||
int delay = 1000;
|
int delay = 1000;
|
||||||
|
|
||||||
Response<File.FileConfiguration> fileConfig = Task.Run(async () => await _fileConfigurationRepository.Get()).Result;
|
Response<File.FileConfiguration> fileConfig = Task.Run(async () => await _fileConfigurationRepository.Get()).Result;
|
||||||
if (fileConfig?.Data?.GlobalConfiguration?.ServiceDiscoveryProvider != null &&
|
if (fileConfig?.Data?.GlobalConfiguration?.ServiceDiscoveryProvider != null &&
|
||||||
!fileConfig.IsError &&
|
!fileConfig.IsError &&
|
||||||
fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval > 0) {
|
fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval > 0)
|
||||||
|
{
|
||||||
delay = fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval;
|
delay = fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Response<IInternalConfiguration> internalConfig = _internalConfigRepo.Get();
|
Response<IInternalConfiguration> internalConfig = _internalConfigRepo.Get();
|
||||||
if (internalConfig?.Data?.ServiceProviderConfiguration != null &&
|
if (internalConfig?.Data?.ServiceProviderConfiguration != null &&
|
||||||
!internalConfig.IsError &&
|
!internalConfig.IsError &&
|
||||||
internalConfig.Data.ServiceProviderConfiguration.PollingInterval > 0) {
|
internalConfig.Data.ServiceProviderConfiguration.PollingInterval > 0)
|
||||||
|
{
|
||||||
delay = internalConfig.Data.ServiceProviderConfiguration.PollingInterval;
|
delay = internalConfig.Data.ServiceProviderConfiguration.PollingInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Repository
|
namespace Ocelot.Configuration.Repository
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ namespace Ocelot.Configuration.Repository
|
|||||||
{
|
{
|
||||||
string jsonConfiguration;
|
string jsonConfiguration;
|
||||||
|
|
||||||
lock(_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
jsonConfiguration = System.IO.File.ReadAllText(_environmentFilePath);
|
jsonConfiguration = System.IO.File.ReadAllText(_environmentFilePath);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ namespace Ocelot.Configuration.Repository
|
|||||||
{
|
{
|
||||||
string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented);
|
string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented);
|
||||||
|
|
||||||
lock(_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (System.IO.File.Exists(_environmentFilePath))
|
if (System.IO.File.Exists(_environmentFilePath))
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user