diff --git a/.travis.yml b/.travis.yml
index aba3d71a..bd3ea077 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ os:
# Ubuntu 14.04
sudo: required
-dist: trusty
+dist: bionic
# OS X 10.12
osx_image: xcode9.2
@@ -13,7 +13,7 @@ osx_image: xcode9.2
mono:
- 5.10.0
-dotnet: 2.1.500
+dotnet: 2.2.105
before_install:
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..2def6a21
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,16 @@
+
+
+ latest
+
+ git
+ https://github.com/ThreeMammals/Ocelot
+
+ true
+
+ true
+ snupkg
+
+
+
+
+
diff --git a/README.md b/README.md
index 222d9abc..9b13aaa0 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,21 @@
[
](http://threemammals.com/ocelot)
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor)
+
[](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis)
+[](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=4&branchName=develop) Windows
+
+[](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=3&branchName=develop) MacOS
+
+[](https://dev.azure.com/ThreeMammals/Ocelot/_build/latest?definitionId=2&branchName=develop) Linux
+
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
[](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop)
+
+
# Ocelot
Ocelot is a .NET API Gateway. This project is aimed at people using .NET running
diff --git a/docs/features/authentication.rst b/docs/features/authentication.rst
index ba230a81..641ca2ed 100644
--- a/docs/features/authentication.rst
+++ b/docs/features/authentication.rst
@@ -93,7 +93,7 @@ Then map the authentication provider key to a ReRoute in your configuration e.g.
Identity Server Bearer Tokens
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-In order to use IdentityServer bearer tokens register your IdentityServer services as usual in ConfigureServices with a scheme (key). If you don't understand how to do this please consult the IdentityServer documentation.
+In order to use IdentityServer bearer tokens, register your IdentityServer services as usual in ConfigureServices with a scheme (key). If you don't understand how to do this please consult the IdentityServer documentation.
.. code-block:: csharp
diff --git a/docs/features/qualityofservice.rst b/docs/features/qualityofservice.rst
index 512ffaad..9839b2f7 100644
--- a/docs/features/qualityofservice.rst
+++ b/docs/features/qualityofservice.rst
@@ -26,15 +26,15 @@ Then add the following section to a ReRoute configuration.
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking":3,
- "DurationOfBreak":5,
+ "DurationOfBreak":1000,
"TimeoutValue":5000
}
You must set a number greater than 0 against ExceptionsAllowedBeforeBreaking for this rule to be
-implemented. Duration of break is how long the circuit breaker will stay open for after it is tripped.
+implemented. Duration of break means the circuit breaker will stay open for 1 second after it is tripped.
TimeoutValue means if a request takes more than 5 seconds it will automatically be timed out.
-You can set the TimeoutValue in isoldation of the ExceptionsAllowedBeforeBreaking and DurationOfBreak options.
+You can set the TimeoutValue in isolation of the ExceptionsAllowedBeforeBreaking and DurationOfBreak options.
.. code-block:: json
diff --git a/docs/features/ratelimiting.rst b/docs/features/ratelimiting.rst
index 547d032f..4dd0354f 100644
--- a/docs/features/ratelimiting.rst
+++ b/docs/features/ratelimiting.rst
@@ -18,9 +18,13 @@ OK so to get rate limiting working for a ReRoute you need to add the following j
}
ClientWhitelist - This is an array that contains the whitelist of the client. It means that the client in this array will not be affected by the rate limiting.
+
EnableRateLimiting - This value specifies enable endpoint rate limiting.
+
Period - This value specifies the period that the limit applies to, such as 1s, 5m, 1h,1d and so on. If you make more requests in the period than the limit allows then you need to wait for PeriodTimespan to elapse before you make another request.
+
PeriodTimespan - This value specifies that we can retry after a certain number of seconds.
+
Limit - This value specifies the maximum number of requests that a client can make in a defined period.
You can also set the following in the GlobalConfiguration part of ocelot.json
@@ -34,7 +38,10 @@ You can also set the following in the GlobalConfiguration part of ocelot.json
"ClientIdHeader" : "Test"
}
-DisableRateLimitHeaders - This value specifies whether X-Rate-Limit and Rety-After headers are disabled.
+DisableRateLimitHeaders - This value specifies whether X-Rate-Limit and Retry-After headers are disabled.
+
QuotaExceededMessage - This value specifies the exceeded message.
+
HttpStatusCode - This value specifies the returned HTTP Status code when rate limiting occurs.
+
ClientIdHeader - Allows you to specifiy the header that should be used to identify clients. By default it is "ClientId"
diff --git a/docs/features/routing.rst b/docs/features/routing.rst
index 0f2e5efc..18cc60c1 100644
--- a/docs/features/routing.rst
+++ b/docs/features/routing.rst
@@ -37,7 +37,7 @@ The DownstreamPathTemplate, DownstreamScheme and DownstreamHostAndPorts define t
DownstreamHostAndPorts is a collection that defines the host and port of any downstream services that you wish to forward requests to.
Usually this will just contain a single entry but sometimes you might want to load balance requests to your downstream services and Ocelot allows you add more than one entry and then select a load balancer.
-The UpstreamPathTemplate is the URL that Ocelot will use to identity which DownstreamPathTemplate to use for a given request.
+The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request.
The UpstreamHttpMethod is used so Ocelot can distinguish between requests with different HTTP verbs to the same URL. You can set a specific list of HTTP Methods or set an empty list to allow any of them.
In Ocelot you can add placeholders for variables to your Templates in the form of {something}.
diff --git a/global.json b/global.json
deleted file mode 100644
index 1738b35f..00000000
--- a/global.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "projects": [ "src", "test" ],
- "sdk": {
- "version": "2.1.500"
- }
-}
diff --git a/samples/OcelotEureka/ApiGateway/ApiGateway.csproj b/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
index 8e6acdb8..a1fe22dd 100644
--- a/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
+++ b/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.0
+ netcoreapp2.2
@@ -15,8 +15,10 @@
-
-
+
+
+
+
diff --git a/samples/OcelotEureka/ApiGateway/Program.cs b/samples/OcelotEureka/ApiGateway/Program.cs
index d72d8644..f2cd87f9 100644
--- a/samples/OcelotEureka/ApiGateway/Program.cs
+++ b/samples/OcelotEureka/ApiGateway/Program.cs
@@ -1,4 +1,7 @@
-namespace ApiGateway
+using Ocelot.Provider.Eureka;
+using Ocelot.Provider.Polly;
+
+namespace ApiGateway
{
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
@@ -27,7 +30,9 @@
})
.ConfigureServices(s =>
{
- s.AddOcelot();
+ s.AddOcelot()
+ .AddEureka()
+ .AddPolly();
})
.Configure(a =>
{
diff --git a/samples/OcelotEureka/DownstreamService/DownstreamService.csproj b/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
index 5e20116d..3d5689a5 100644
--- a/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
+++ b/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.0
+ netcoreapp2.2
@@ -9,7 +9,7 @@
-
+
diff --git a/samples/OcelotGraphQL/OcelotGraphQL.sln b/samples/OcelotGraphQL/OcelotGraphQL.sln
new file mode 100644
index 00000000..f6ded47e
--- /dev/null
+++ b/samples/OcelotGraphQL/OcelotGraphQL.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28803.452
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotGraphQL", "OcelotGraphQL.csproj", "{5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5A3220BF-FE0B-4B26-8B2F-37DB7292EEA9}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5762C36C-EA4B-44D9-9DAA-2F7C3FC98692}
+ EndGlobalSection
+EndGlobal
diff --git a/samples/OcelotGraphQL/Properties/launchSettings.json b/samples/OcelotGraphQL/Properties/launchSettings.json
new file mode 100644
index 00000000..ec10c2c0
--- /dev/null
+++ b/samples/OcelotGraphQL/Properties/launchSettings.json
@@ -0,0 +1,27 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:53639/",
+ "sslPort": 0
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "OcelotGraphQL": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "applicationUrl": "http://localhost:53640/"
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/OelotKube/.dockerignore b/samples/OcelotKube/.dockerignore
similarity index 100%
rename from samples/OelotKube/.dockerignore
rename to samples/OcelotKube/.dockerignore
diff --git a/samples/OelotKube/ApiGateway/ApiGateway.csproj b/samples/OcelotKube/ApiGateway/ApiGateway.csproj
similarity index 68%
rename from samples/OelotKube/ApiGateway/ApiGateway.csproj
rename to samples/OcelotKube/ApiGateway/ApiGateway.csproj
index 0dc4f632..81b47303 100644
--- a/samples/OelotKube/ApiGateway/ApiGateway.csproj
+++ b/samples/OcelotKube/ApiGateway/ApiGateway.csproj
@@ -1,17 +1,17 @@
- netcoreapp2.1
+ netcoreapp2.2
InProcess
Linux
-
-
-
-
+
+
+
+
diff --git a/samples/OelotKube/ApiGateway/Dockerfile b/samples/OcelotKube/ApiGateway/Dockerfile
similarity index 100%
rename from samples/OelotKube/ApiGateway/Dockerfile
rename to samples/OcelotKube/ApiGateway/Dockerfile
diff --git a/samples/OelotKube/ApiGateway/Program.cs b/samples/OcelotKube/ApiGateway/Program.cs
similarity index 100%
rename from samples/OelotKube/ApiGateway/Program.cs
rename to samples/OcelotKube/ApiGateway/Program.cs
diff --git a/samples/OelotKube/ApiGateway/Properties/launchSettings.json b/samples/OcelotKube/ApiGateway/Properties/launchSettings.json
similarity index 100%
rename from samples/OelotKube/ApiGateway/Properties/launchSettings.json
rename to samples/OcelotKube/ApiGateway/Properties/launchSettings.json
diff --git a/samples/OelotKube/ApiGateway/Startup.cs b/samples/OcelotKube/ApiGateway/Startup.cs
similarity index 85%
rename from samples/OelotKube/ApiGateway/Startup.cs
rename to samples/OcelotKube/ApiGateway/Startup.cs
index 4743e836..d7b2473c 100644
--- a/samples/OelotKube/ApiGateway/Startup.cs
+++ b/samples/OcelotKube/ApiGateway/Startup.cs
@@ -1,10 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
diff --git a/samples/OelotKube/ApiGateway/appsettings.Development.json b/samples/OcelotKube/ApiGateway/appsettings.Development.json
similarity index 100%
rename from samples/OelotKube/ApiGateway/appsettings.Development.json
rename to samples/OcelotKube/ApiGateway/appsettings.Development.json
diff --git a/samples/OelotKube/ApiGateway/appsettings.json b/samples/OcelotKube/ApiGateway/appsettings.json
similarity index 100%
rename from samples/OelotKube/ApiGateway/appsettings.json
rename to samples/OcelotKube/ApiGateway/appsettings.json
diff --git a/samples/OelotKube/ApiGateway/ocelot.json b/samples/OcelotKube/ApiGateway/ocelot.json
similarity index 100%
rename from samples/OelotKube/ApiGateway/ocelot.json
rename to samples/OcelotKube/ApiGateway/ocelot.json
diff --git a/samples/OelotKube/Dockerfile b/samples/OcelotKube/Dockerfile
similarity index 100%
rename from samples/OelotKube/Dockerfile
rename to samples/OcelotKube/Dockerfile
diff --git a/samples/OelotKube/DownstreamService/Controllers/ValuesController.cs b/samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs
similarity index 100%
rename from samples/OelotKube/DownstreamService/Controllers/ValuesController.cs
rename to samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs
diff --git a/samples/OelotKube/DownstreamService/Dockerfile b/samples/OcelotKube/DownstreamService/Dockerfile
similarity index 100%
rename from samples/OelotKube/DownstreamService/Dockerfile
rename to samples/OcelotKube/DownstreamService/Dockerfile
diff --git a/samples/OelotKube/DownstreamService/Dockerfile.develop b/samples/OcelotKube/DownstreamService/Dockerfile.develop
similarity index 100%
rename from samples/OelotKube/DownstreamService/Dockerfile.develop
rename to samples/OcelotKube/DownstreamService/Dockerfile.develop
diff --git a/samples/OelotKube/DownstreamService/DownstreamService.csproj b/samples/OcelotKube/DownstreamService/DownstreamService.csproj
similarity index 75%
rename from samples/OelotKube/DownstreamService/DownstreamService.csproj
rename to samples/OcelotKube/DownstreamService/DownstreamService.csproj
index c32dd048..88fdbfb7 100644
--- a/samples/OelotKube/DownstreamService/DownstreamService.csproj
+++ b/samples/OcelotKube/DownstreamService/DownstreamService.csproj
@@ -1,15 +1,15 @@
- netcoreapp2.1
+ netcoreapp2.2
InProcess
Linux
-
-
+
+
diff --git a/samples/OelotKube/DownstreamService/Program.cs b/samples/OcelotKube/DownstreamService/Program.cs
similarity index 100%
rename from samples/OelotKube/DownstreamService/Program.cs
rename to samples/OcelotKube/DownstreamService/Program.cs
diff --git a/samples/OelotKube/DownstreamService/Properties/launchSettings.json b/samples/OcelotKube/DownstreamService/Properties/launchSettings.json
similarity index 100%
rename from samples/OelotKube/DownstreamService/Properties/launchSettings.json
rename to samples/OcelotKube/DownstreamService/Properties/launchSettings.json
diff --git a/samples/OelotKube/DownstreamService/Startup.cs b/samples/OcelotKube/DownstreamService/Startup.cs
similarity index 100%
rename from samples/OelotKube/DownstreamService/Startup.cs
rename to samples/OcelotKube/DownstreamService/Startup.cs
diff --git a/samples/OelotKube/DownstreamService/appsettings.Development.json b/samples/OcelotKube/DownstreamService/appsettings.Development.json
similarity index 100%
rename from samples/OelotKube/DownstreamService/appsettings.Development.json
rename to samples/OcelotKube/DownstreamService/appsettings.Development.json
diff --git a/samples/OelotKube/DownstreamService/appsettings.json b/samples/OcelotKube/DownstreamService/appsettings.json
similarity index 100%
rename from samples/OelotKube/DownstreamService/appsettings.json
rename to samples/OcelotKube/DownstreamService/appsettings.json
diff --git a/samples/OelotKube/OelotKube.sln b/samples/OcelotKube/OcelotKube.sln
similarity index 100%
rename from samples/OelotKube/OelotKube.sln
rename to samples/OcelotKube/OcelotKube.sln
diff --git a/src/Ocelot.Administration/IIdentityServerConfiguration.cs b/src/Ocelot.Administration/IIdentityServerConfiguration.cs
index eb389cf9..cbfa289e 100644
--- a/src/Ocelot.Administration/IIdentityServerConfiguration.cs
+++ b/src/Ocelot.Administration/IIdentityServerConfiguration.cs
@@ -4,10 +4,10 @@ namespace Ocelot.Administration
public interface IIdentityServerConfiguration
{
- string ApiName { get; }
- string ApiSecret { get; }
- bool RequireHttps { get; }
- List AllowedScopes { get; }
+ string ApiName { get; }
+ string ApiSecret { get; }
+ bool RequireHttps { get; }
+ List AllowedScopes { get; }
string CredentialsSigningCertificateLocation { get; }
string CredentialsSigningCertificatePassword { get; }
}
diff --git a/src/Ocelot.Administration/IdentityServerConfiguration.cs b/src/Ocelot.Administration/IdentityServerConfiguration.cs
index 95e64d01..a560f032 100644
--- a/src/Ocelot.Administration/IdentityServerConfiguration.cs
+++ b/src/Ocelot.Administration/IdentityServerConfiguration.cs
@@ -5,11 +5,11 @@ namespace Ocelot.Administration
public class IdentityServerConfiguration : IIdentityServerConfiguration
{
public IdentityServerConfiguration(
- string apiName,
- bool requireHttps,
+ string apiName,
+ bool requireHttps,
string apiSecret,
List allowedScopes,
- string credentialsSigningCertificateLocation,
+ string credentialsSigningCertificateLocation,
string credentialsSigningCertificatePassword)
{
ApiName = apiName;
diff --git a/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs b/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
index 3ad31b69..b4b8994a 100644
--- a/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
@@ -1,11 +1,10 @@
namespace Ocelot.Administration
{
- using System.Threading.Tasks;
- using Configuration;
using Configuration.Repository;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Middleware;
+ using System.Threading.Tasks;
public static class IdentityServerMiddlewareConfigurationProvider
{
diff --git a/src/Ocelot.Administration/Ocelot.Administration.csproj b/src/Ocelot.Administration/Ocelot.Administration.csproj
index ca518938..a4aabbd8 100644
--- a/src/Ocelot.Administration/Ocelot.Administration.csproj
+++ b/src/Ocelot.Administration/Ocelot.Administration.csproj
@@ -29,10 +29,10 @@
-
+
all
-
-
+
+
diff --git a/src/Ocelot.Administration/OcelotBuilderExtensions.cs b/src/Ocelot.Administration/OcelotBuilderExtensions.cs
index caafa4df..207b3bcf 100644
--- a/src/Ocelot.Administration/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Administration/OcelotBuilderExtensions.cs
@@ -1,14 +1,6 @@
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 IdentityModel;
using IdentityServer4.AccessTokenValidation;
using IdentityServer4.Models;
using Microsoft.AspNetCore.Builder;
@@ -16,6 +8,10 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Ocelot.Middleware;
+ using System;
+ using System.Collections.Generic;
+ using System.IdentityModel.Tokens.Jwt;
+ using System.Security.Cryptography.X509Certificates;
public static class OcelotBuilderExtensions
{
@@ -61,7 +57,8 @@
{
builder.Services.TryAddSingleton(identityServerConfiguration);
var identityServerBuilder = builder.Services
- .AddIdentityServer(o => {
+ .AddIdentityServer(o =>
+ {
o.IssuerUri = "Ocelot";
})
.AddInMemoryApiResources(Resources(identityServerConfiguration))
diff --git a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
index 32271347..7941dcab 100644
--- a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
+++ b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
@@ -28,11 +28,11 @@
-
+
all
-
-
-
+
+
+
diff --git a/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs b/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
index e9841890..7a2c2d86 100644
--- a/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Cache.CacheManager
{
- using System;
using Configuration;
using Configuration.File;
using DependencyInjection;
using global::CacheManager.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
+ using System;
public static class OcelotBuilderExtensions
{
diff --git a/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs b/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
index 7165edb5..a95df4c4 100644
--- a/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
+++ b/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Cache.CacheManager
{
- using System;
using global::CacheManager.Core;
+ using System;
public class OcelotCacheManagerCache : IOcelotCache
{
diff --git a/src/Ocelot.Provider.Consul/Consul.cs b/src/Ocelot.Provider.Consul/Consul.cs
index 3aac63b6..f300aa6e 100644
--- a/src/Ocelot.Provider.Consul/Consul.cs
+++ b/src/Ocelot.Provider.Consul/Consul.cs
@@ -1,16 +1,15 @@
namespace Ocelot.Provider.Consul
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
using global::Consul;
using Infrastructure.Extensions;
using Logging;
using ServiceDiscovery.Providers;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
using Values;
-
public class Consul : IServiceDiscoveryProvider
{
private readonly ConsulRegistryConfiguration _config;
@@ -35,7 +34,16 @@
{
if (IsValid(serviceEntry))
{
- services.Add(BuildService(serviceEntry));
+ var nodes = await _consul.Catalog.Nodes();
+ if (nodes.Response == null)
+ {
+ services.Add(BuildService(serviceEntry, null));
+ }
+ else
+ {
+ var serviceNode = nodes.Response.FirstOrDefault(n => n.Address == serviceEntry.Service.Address);
+ services.Add(BuildService(serviceEntry, serviceNode));
+ }
}
else
{
@@ -46,11 +54,11 @@
return services.ToList();
}
- private Service BuildService(ServiceEntry serviceEntry)
+ private Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
{
return new Service(
serviceEntry.Service.Service,
- new ServiceHostAndPort(serviceEntry.Service.Address, serviceEntry.Service.Port),
+ new ServiceHostAndPort(serviceNode == null ? serviceEntry.Service.Address : serviceNode.Name, serviceEntry.Service.Port),
serviceEntry.Service.ID,
GetVersionFromStrings(serviceEntry.Service.Tags),
serviceEntry.Service.Tags ?? Enumerable.Empty());
diff --git a/src/Ocelot.Provider.Consul/ConsulClientFactory.cs b/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
index de1f30aa..f3f0e54f 100644
--- a/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
+++ b/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Provider.Consul
{
- using System;
using global::Consul;
+ using System;
public class ConsulClientFactory : IConsulClientFactory
{
diff --git a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
index 01273a35..7d7f4d44 100644
--- a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
+++ b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
@@ -1,14 +1,14 @@
namespace Ocelot.Provider.Consul
{
- using System;
- using System.Text;
- using System.Threading.Tasks;
using Configuration.File;
using Configuration.Repository;
using global::Consul;
using Logging;
using Newtonsoft.Json;
using Responses;
+ using System;
+ using System.Text;
+ using System.Threading.Tasks;
public class ConsulFileConfigurationRepository : IFileConfigurationRepository
{
diff --git a/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs b/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs
index a25d3752..1b89b4f3 100644
--- a/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs
@@ -1,8 +1,5 @@
namespace Ocelot.Provider.Consul
{
- using System;
- using System.Linq;
- using System.Threading.Tasks;
using Configuration.Creator;
using Configuration.File;
using Configuration.Repository;
@@ -11,6 +8,9 @@
using Microsoft.Extensions.Options;
using Middleware;
using Responses;
+ using System;
+ using System.Linq;
+ using System.Threading.Tasks;
public static class ConsulMiddlewareConfigurationProvider
{
diff --git a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
index 53095404..cdf422b8 100644
--- a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
+++ b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
@@ -1,8 +1,6 @@
namespace Ocelot.Provider.Consul
{
- using System.Threading.Tasks;
using Logging;
- using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using ServiceDiscovery;
diff --git a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
index e0ae127e..2df87ad4 100644
--- a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
+++ b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
@@ -30,7 +30,7 @@
-
+
all
diff --git a/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
index addbac91..ce2ed95b 100644
--- a/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
@@ -3,6 +3,7 @@
using Configuration.Repository;
using DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.DependencyInjection.Extensions;
using Middleware;
using ServiceDiscovery;
@@ -12,6 +13,8 @@
{
builder.Services.AddSingleton(ConsulProviderFactory.Get);
builder.Services.AddSingleton();
+ builder.Services.RemoveAll(typeof(IFileConfigurationPollerOptions));
+ builder.Services.AddSingleton();
return builder;
}
diff --git a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
index 32470153..15abc777 100644
--- a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
+++ b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Consul
{
+ using Logging;
+ using ServiceDiscovery.Providers;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
- using Logging;
- using ServiceDiscovery.Providers;
using Values;
public class PollConsul : IServiceDiscoveryProvider
diff --git a/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs b/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
index b0163916..bc3103ac 100644
--- a/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
+++ b/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
@@ -4,7 +4,7 @@
public class UnableToSetConfigInConsulError : Error
{
- public UnableToSetConfigInConsulError(string s)
+ public UnableToSetConfigInConsulError(string s)
: base(s, OcelotErrorCode.UnknownError)
{
}
diff --git a/src/Ocelot.Provider.Eureka/Eureka.cs b/src/Ocelot.Provider.Eureka/Eureka.cs
index b4f5fd3b..8316beac 100644
--- a/src/Ocelot.Provider.Eureka/Eureka.cs
+++ b/src/Ocelot.Provider.Eureka/Eureka.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Eureka
{
+ using ServiceDiscovery.Providers;
+ using Steeltoe.Common.Discovery;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
- using ServiceDiscovery.Providers;
- using Steeltoe.Common.Discovery;
using Values;
public class Eureka : IServiceDiscoveryProvider
diff --git a/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs b/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
index ac6bba72..f893ed72 100644
--- a/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
@@ -1,11 +1,11 @@
namespace Ocelot.Provider.Eureka
{
- using System.Threading.Tasks;
using Configuration;
using Configuration.Repository;
using Microsoft.Extensions.DependencyInjection;
using Middleware;
using Steeltoe.Discovery.Client;
+ using System.Threading.Tasks;
public class EurekaMiddlewareConfigurationProvider
{
diff --git a/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs b/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs
index b35fe7c8..9fdea310 100644
--- a/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs
+++ b/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs
@@ -2,7 +2,6 @@
{
using Microsoft.Extensions.DependencyInjection;
using ServiceDiscovery;
- using ServiceDiscovery.Providers;
using Steeltoe.Common.Discovery;
public static class EurekaProviderFactory
diff --git a/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj b/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj
index 6373e90a..d25efc5a 100644
--- a/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj
+++ b/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj
@@ -30,7 +30,7 @@
-
+
all
diff --git a/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
index 0e69d433..4a246e4f 100644
--- a/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Provider.Eureka
{
- using System.Linq;
using DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Middleware;
- using Steeltoe.Discovery.Client;
using ServiceDiscovery;
+ using Steeltoe.Discovery.Client;
+ using System.Linq;
public static class OcelotBuilderExtensions
{
diff --git a/src/Ocelot.Provider.Kubernetes/KubeRegistryConfiguration.cs b/src/Ocelot.Provider.Kubernetes/KubeRegistryConfiguration.cs
index 5c35bbeb..3aea206e 100644
--- a/src/Ocelot.Provider.Kubernetes/KubeRegistryConfiguration.cs
+++ b/src/Ocelot.Provider.Kubernetes/KubeRegistryConfiguration.cs
@@ -1,7 +1,4 @@
-using KubeClient;
-using System;
-
-namespace Ocelot.Provider.Kubernetes
+namespace Ocelot.Provider.Kubernetes
{
public class KubeRegistryConfiguration
{
diff --git a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
index 13a73143..436585da 100644
--- a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
+++ b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
@@ -30,8 +30,8 @@
-
-
+
+
diff --git a/src/Ocelot.Provider.Polly/CircuitBreaker.cs b/src/Ocelot.Provider.Polly/CircuitBreaker.cs
index 762749d6..8d4c6d4c 100644
--- a/src/Ocelot.Provider.Polly/CircuitBreaker.cs
+++ b/src/Ocelot.Provider.Polly/CircuitBreaker.cs
@@ -1,15 +1,13 @@
+using Polly;
using System.Collections.Generic;
using System.Linq;
-using Polly;
-using Polly.CircuitBreaker;
-using Polly.Timeout;
namespace Ocelot.Provider.Polly
{
public class CircuitBreaker
{
private readonly List _policies = new List();
-
+
public CircuitBreaker(params IAsyncPolicy[] policies)
{
foreach (var policy in policies.Where(p => p != null))
@@ -17,7 +15,7 @@ namespace Ocelot.Provider.Polly
this._policies.Add(policy);
}
}
-
+
public IAsyncPolicy[] Policies => this._policies.ToArray();
}
}
diff --git a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
index e4512cec..fa15a189 100644
--- a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
+++ b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
@@ -29,9 +29,9 @@
-
+
all
-
+
diff --git a/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
index ae7e881c..f753d9d3 100644
--- a/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
@@ -1,9 +1,5 @@
namespace Ocelot.Provider.Polly
{
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using System.Threading.Tasks;
using Configuration;
using DependencyInjection;
using Errors;
@@ -12,6 +8,10 @@
using Logging;
using Microsoft.Extensions.DependencyInjection;
using Requester;
+ using System;
+ using System.Collections.Generic;
+ using System.Net.Http;
+ using System.Threading.Tasks;
public static class OcelotBuilderExtensions
{
@@ -31,7 +31,7 @@
return new PollyCircuitBreakingDelegatingHandler(new PollyQoSProvider(reRoute, logger), logger);
}
- builder.Services.AddSingleton((QosDelegatingHandlerDelegate) QosDelegatingHandlerDelegate);
+ builder.Services.AddSingleton((QosDelegatingHandlerDelegate)QosDelegatingHandlerDelegate);
return builder;
}
}
diff --git a/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs b/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
index 2e5bb5a9..8bdcaa4a 100644
--- a/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
+++ b/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
@@ -1,9 +1,9 @@
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
using Ocelot.Logging;
using Polly;
using Polly.CircuitBreaker;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
namespace Ocelot.Provider.Polly
{
@@ -26,11 +26,11 @@ namespace Ocelot.Provider.Polly
{
return await Policy
.WrapAsync(_qoSProvider.CircuitBreaker.Policies)
- .ExecuteAsync(() => base.SendAsync(request,cancellationToken));
+ .ExecuteAsync(() => base.SendAsync(request, cancellationToken));
}
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;
}
catch (HttpRequestException ex)
diff --git a/src/Ocelot.Provider.Polly/PollyQoSProvider.cs b/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
index 3d34195f..3f2c6720 100644
--- a/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
+++ b/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
@@ -1,17 +1,17 @@
namespace Ocelot.Provider.Polly
{
- using System;
- using System.Net.Http;
using global::Polly;
using global::Polly.CircuitBreaker;
using global::Polly.Timeout;
using Ocelot.Configuration;
using Ocelot.Logging;
+ using System;
+ using System.Net.Http;
public class PollyQoSProvider
{
- private readonly CircuitBreakerPolicy _circuitBreakerPolicy;
- private readonly TimeoutPolicy _timeoutPolicy;
+ private readonly AsyncCircuitBreakerPolicy _circuitBreakerPolicy;
+ private readonly AsyncTimeoutPolicy _timeoutPolicy;
private readonly IOcelotLogger _logger;
public PollyQoSProvider(DownstreamReRoute reRoute, IOcelotLoggerFactory loggerFactory)
diff --git a/src/Ocelot.Provider.Polly/RequestTimedOutError.cs b/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
index 4e910b12..63ad74ae 100644
--- a/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
+++ b/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Provider.Polly
{
- using System;
using Errors;
+ using System;
public class RequestTimedOutError : Error
{
diff --git a/src/Ocelot.Provider.Rafty/FilePeersProvider.cs b/src/Ocelot.Provider.Rafty/FilePeersProvider.cs
index 1f9300bc..ddca1ac2 100644
--- a/src/Ocelot.Provider.Rafty/FilePeersProvider.cs
+++ b/src/Ocelot.Provider.Rafty/FilePeersProvider.cs
@@ -1,14 +1,13 @@
namespace Ocelot.Provider.Rafty
{
- using System.Net.Http;
- using Configuration;
+ using Administration;
using Configuration.Repository;
using global::Rafty.Concensus.Peers;
using global::Rafty.Infrastructure;
using Microsoft.Extensions.Options;
using Middleware;
using System.Collections.Generic;
- using Administration;
+ using System.Net.Http;
public class FilePeersProvider : IPeersProvider
{
diff --git a/src/Ocelot.Provider.Rafty/HttpPeer.cs b/src/Ocelot.Provider.Rafty/HttpPeer.cs
index 11397293..c3ed9e65 100644
--- a/src/Ocelot.Provider.Rafty/HttpPeer.cs
+++ b/src/Ocelot.Provider.Rafty/HttpPeer.cs
@@ -1,7 +1,6 @@
namespace Ocelot.Provider.Rafty
{
- using System.Net.Http;
- using System.Threading.Tasks;
+ using Administration;
using Configuration;
using global::Rafty.Concensus.Messages;
using global::Rafty.Concensus.Peers;
@@ -11,7 +10,8 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
- using Administration;
+ using System.Net.Http;
+ using System.Threading.Tasks;
public class HttpPeer : IPeer
{
diff --git a/src/Ocelot.Provider.Rafty/Ocelot.Provider.Rafty.csproj b/src/Ocelot.Provider.Rafty/Ocelot.Provider.Rafty.csproj
index 1e21afc3..f7e0996c 100644
--- a/src/Ocelot.Provider.Rafty/Ocelot.Provider.Rafty.csproj
+++ b/src/Ocelot.Provider.Rafty/Ocelot.Provider.Rafty.csproj
@@ -30,9 +30,9 @@
-
-
-
+
+
+
all
diff --git a/src/Ocelot.Provider.Rafty/OcelotFiniteStateMachine.cs b/src/Ocelot.Provider.Rafty/OcelotFiniteStateMachine.cs
index c7dd3ef6..b054852e 100644
--- a/src/Ocelot.Provider.Rafty/OcelotFiniteStateMachine.cs
+++ b/src/Ocelot.Provider.Rafty/OcelotFiniteStateMachine.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Provider.Rafty
{
- using System.Threading.Tasks;
using Configuration.Setter;
using global::Rafty.FiniteStateMachine;
using global::Rafty.Log;
+ using System.Threading.Tasks;
public class OcelotFiniteStateMachine : IFiniteStateMachine
{
diff --git a/src/Ocelot.Provider.Rafty/RaftController.cs b/src/Ocelot.Provider.Rafty/RaftController.cs
index 9cf51dd6..a8006cdc 100644
--- a/src/Ocelot.Provider.Rafty/RaftController.cs
+++ b/src/Ocelot.Provider.Rafty/RaftController.cs
@@ -1,8 +1,5 @@
namespace Ocelot.Provider.Rafty
{
- using System;
- using System.IO;
- using System.Threading.Tasks;
using global::Rafty.Concensus.Messages;
using global::Rafty.Concensus.Node;
using global::Rafty.FiniteStateMachine;
@@ -11,6 +8,9 @@
using Microsoft.AspNetCore.Mvc;
using Middleware;
using Newtonsoft.Json;
+ using System;
+ using System.IO;
+ using System.Threading.Tasks;
[Authorize]
[Route("raft")]
diff --git a/src/Ocelot.Provider.Rafty/RaftyFileConfigurationSetter.cs b/src/Ocelot.Provider.Rafty/RaftyFileConfigurationSetter.cs
index bf26ab07..21fc97a8 100644
--- a/src/Ocelot.Provider.Rafty/RaftyFileConfigurationSetter.cs
+++ b/src/Ocelot.Provider.Rafty/RaftyFileConfigurationSetter.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Provider.Rafty
{
- using System.Threading.Tasks;
using Configuration.File;
using Configuration.Setter;
using global::Rafty.Concensus.Node;
using global::Rafty.Infrastructure;
+ using System.Threading.Tasks;
public class RaftyFileConfigurationSetter : IFileConfigurationSetter
{
diff --git a/src/Ocelot.Provider.Rafty/RaftyMiddlewareConfigurationProvider.cs b/src/Ocelot.Provider.Rafty/RaftyMiddlewareConfigurationProvider.cs
index e8c3ad5c..62e9711d 100644
--- a/src/Ocelot.Provider.Rafty/RaftyMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Provider.Rafty/RaftyMiddlewareConfigurationProvider.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Provider.Rafty
{
- using System.Threading.Tasks;
using global::Rafty.Concensus.Node;
using global::Rafty.Infrastructure;
using Microsoft.AspNetCore.Builder;
+ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Middleware;
- using Microsoft.AspNetCore.Hosting;
+ using System.Threading.Tasks;
public static class RaftyMiddlewareConfigurationProvider
{
diff --git a/src/Ocelot.Provider.Rafty/SqlLiteLog.cs b/src/Ocelot.Provider.Rafty/SqlLiteLog.cs
index 618b4851..1be1645e 100644
--- a/src/Ocelot.Provider.Rafty/SqlLiteLog.cs
+++ b/src/Ocelot.Provider.Rafty/SqlLiteLog.cs
@@ -1,15 +1,15 @@
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.Log;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Threading;
+ using System.Threading.Tasks;
public class SqlLiteLog : ILog
{
diff --git a/src/Ocelot.Provider.Rafty/UnableToSaveAcceptCommand.cs b/src/Ocelot.Provider.Rafty/UnableToSaveAcceptCommand.cs
index 888987ba..1a9f12e2 100644
--- a/src/Ocelot.Provider.Rafty/UnableToSaveAcceptCommand.cs
+++ b/src/Ocelot.Provider.Rafty/UnableToSaveAcceptCommand.cs
@@ -1,9 +1,10 @@
namespace Ocelot.Provider.Rafty
{
using Errors;
+
public class UnableToSaveAcceptCommand : Error
{
- public UnableToSaveAcceptCommand(string message)
+ public UnableToSaveAcceptCommand(string message)
: base(message, OcelotErrorCode.UnknownError)
{
}
diff --git a/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs b/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
index d8d1dd84..3cd63eb0 100644
--- a/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
+++ b/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
@@ -1,17 +1,17 @@
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.Tracing;
using global::Butterfly.OpenTracing;
using Infrastructure.Extensions;
using Microsoft.AspNetCore.Http;
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
{
@@ -25,7 +25,7 @@
public void Event(HttpContext httpContext, string @event)
{
- // todo - if the user isnt using tracing the code gets here and will blow up on
+ // todo - if the user isnt using tracing the code gets here and will blow up on
// _tracer.Tracer.TryExtract..
if (_tracer == null)
{
@@ -52,8 +52,8 @@
public Task SendAsync(
HttpRequestMessage request,
- CancellationToken cancellationToken,
- Action addTraceIdToRepo,
+ CancellationToken cancellationToken,
+ Action addTraceIdToRepo,
Func> baseSendAsync)
{
return _tracer.ChildTraceAsync($"httpclient {request.Method}", DateTimeOffset.UtcNow, span => TracingSendAsync(span, request, cancellationToken, addTraceIdToRepo, baseSendAsync));
@@ -62,8 +62,8 @@
protected virtual async Task TracingSendAsync(
ISpan span,
HttpRequestMessage request,
- CancellationToken cancellationToken,
- Action addTraceIdToRepo,
+ CancellationToken cancellationToken,
+ Action addTraceIdToRepo,
Func> baseSendAsync)
{
if (request.Headers.Contains(PrefixSpanId))
diff --git a/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs b/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
index 4a543a2e..8c67f0df 100644
--- a/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Tracing.Butterfly
{
- using System;
using DependencyInjection;
using global::Butterfly.Client.AspNetCore;
using Logging;
using Microsoft.Extensions.DependencyInjection;
+ using System;
public static class OcelotBuilderExtensions
{
diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
index af7f5791..942e8cac 100644
--- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
+++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
@@ -1,11 +1,8 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Authentication;
using Ocelot.Configuration;
-using Ocelot.Errors;
-using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging;
using Ocelot.Middleware;
+using System.Threading.Tasks;
namespace Ocelot.Authentication.Middleware
{
diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareMiddlewareExtensions.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareMiddlewareExtensions.cs
index 27b0f197..edd49f32 100644
--- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareMiddlewareExtensions.cs
+++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddlewareMiddlewareExtensions.cs
@@ -9,4 +9,4 @@ namespace Ocelot.Authentication.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/ClaimValueNotAuthorisedError.cs b/src/Ocelot/Authorisation/ClaimValueNotAuthorisedError.cs
index 9d552205..d0535624 100644
--- a/src/Ocelot/Authorisation/ClaimValueNotAuthorisedError.cs
+++ b/src/Ocelot/Authorisation/ClaimValueNotAuthorisedError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
{
public class ClaimValueNotAuthorisedError : Error
{
- public ClaimValueNotAuthorisedError(string message)
+ public ClaimValueNotAuthorisedError(string message)
: base(message, OcelotErrorCode.ClaimValueNotAuthorisedError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/ClaimsAuthoriser.cs b/src/Ocelot/Authorisation/ClaimsAuthoriser.cs
index 75a166f2..5ae95e91 100644
--- a/src/Ocelot/Authorisation/ClaimsAuthoriser.cs
+++ b/src/Ocelot/Authorisation/ClaimsAuthoriser.cs
@@ -1,14 +1,10 @@
-using System;
+using Ocelot.DownstreamRouteFinder.UrlMatcher;
+using Ocelot.Responses;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.RegularExpressions;
-using Ocelot.DownstreamRouteFinder.UrlMatcher;
-using Ocelot.Middleware;
-using Ocelot.Responses;
-using Ocelot.Values;
-
namespace Ocelot.Authorisation
{
using Infrastructure.Claims.Parser;
@@ -26,7 +22,8 @@ namespace Ocelot.Authorisation
ClaimsPrincipal claimsPrincipal,
Dictionary routeClaimsRequirement,
List urlPathPlaceholderNameAndValues
- ){
+ )
+ {
foreach (var required in routeClaimsRequirement)
{
var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
@@ -62,15 +59,14 @@ namespace Ocelot.Authorisation
if (matchingPlaceholders.Length == 0)
{
return new ErrorResponse(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
{
return new ErrorResponse(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
{
@@ -92,4 +88,4 @@ namespace Ocelot.Authorisation
return new OkResponse(true);
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/IClaimsAuthoriser.cs b/src/Ocelot/Authorisation/IClaimsAuthoriser.cs
index 9f9ce3f8..5e4b9c59 100644
--- a/src/Ocelot/Authorisation/IClaimsAuthoriser.cs
+++ b/src/Ocelot/Authorisation/IClaimsAuthoriser.cs
@@ -1,9 +1,6 @@
-using System.Security.Claims;
-
-using Ocelot.Configuration;
-using Ocelot.DownstreamRouteFinder.UrlMatcher;
+using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
-using Ocelot.Values;
+using System.Security.Claims;
namespace Ocelot.Authorisation
{
@@ -17,4 +14,4 @@ namespace Ocelot.Authorisation
List urlPathPlaceholderNameAndValues
);
}
-}
+}
diff --git a/src/Ocelot/Authorisation/IScopesAuthoriser.cs b/src/Ocelot/Authorisation/IScopesAuthoriser.cs
index a6a1396c..57047ce7 100644
--- a/src/Ocelot/Authorisation/IScopesAuthoriser.cs
+++ b/src/Ocelot/Authorisation/IScopesAuthoriser.cs
@@ -1,5 +1,5 @@
-using System.Security.Claims;
-using Ocelot.Responses;
+using Ocelot.Responses;
+using System.Security.Claims;
namespace Ocelot.Authorisation
{
@@ -9,4 +9,4 @@ namespace Ocelot.Authorisation
{
Response Authorise(ClaimsPrincipal claimsPrincipal, List routeAllowedScopes);
}
-}
+}
diff --git a/src/Ocelot/Authorisation/Middleware/AuthorisationMiddleware.cs b/src/Ocelot/Authorisation/Middleware/AuthorisationMiddleware.cs
index 8e906d5c..cc5cfda8 100644
--- a/src/Ocelot/Authorisation/Middleware/AuthorisationMiddleware.cs
+++ b/src/Ocelot/Authorisation/Middleware/AuthorisationMiddleware.cs
@@ -1,12 +1,10 @@
namespace Ocelot.Authorisation.Middleware
{
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Errors;
- using Ocelot.Middleware;
- using Logging;
- using Responses;
using Configuration;
+ using Logging;
+ using Ocelot.Middleware;
+ using Responses;
+ using System.Threading.Tasks;
public class AuthorisationMiddleware : OcelotMiddleware
{
@@ -18,7 +16,7 @@
IClaimsAuthoriser claimsAuthoriser,
IScopesAuthoriser scopesAuthoriser,
IOcelotLoggerFactory loggerFactory)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_claimsAuthoriser = claimsAuthoriser;
@@ -102,4 +100,4 @@
return reRoute.IsAuthorised;
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/Middleware/AuthorisationMiddlewareMiddlewareExtensions.cs b/src/Ocelot/Authorisation/Middleware/AuthorisationMiddlewareMiddlewareExtensions.cs
index df00eb6b..a4999381 100644
--- a/src/Ocelot/Authorisation/Middleware/AuthorisationMiddlewareMiddlewareExtensions.cs
+++ b/src/Ocelot/Authorisation/Middleware/AuthorisationMiddlewareMiddlewareExtensions.cs
@@ -9,4 +9,4 @@ namespace Ocelot.Authorisation.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/ScopeNotAuthorisedError.cs b/src/Ocelot/Authorisation/ScopeNotAuthorisedError.cs
index d99e1abd..1abf5715 100644
--- a/src/Ocelot/Authorisation/ScopeNotAuthorisedError.cs
+++ b/src/Ocelot/Authorisation/ScopeNotAuthorisedError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
{
public class ScopeNotAuthorisedError : Error
{
- public ScopeNotAuthorisedError(string message)
+ public ScopeNotAuthorisedError(string message)
: base(message, OcelotErrorCode.ScopeNotAuthorisedError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/ScopesAuthoriser.cs b/src/Ocelot/Authorisation/ScopesAuthoriser.cs
index 6d7a8d57..8344d80b 100644
--- a/src/Ocelot/Authorisation/ScopesAuthoriser.cs
+++ b/src/Ocelot/Authorisation/ScopesAuthoriser.cs
@@ -1,7 +1,7 @@
using Ocelot.Responses;
using System.Collections.Generic;
-using System.Security.Claims;
using System.Linq;
+using System.Security.Claims;
namespace Ocelot.Authorisation
{
diff --git a/src/Ocelot/Authorisation/UnauthorisedError.cs b/src/Ocelot/Authorisation/UnauthorisedError.cs
index 2a594d72..5e8f054c 100644
--- a/src/Ocelot/Authorisation/UnauthorisedError.cs
+++ b/src/Ocelot/Authorisation/UnauthorisedError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
{
public class UnauthorisedError : Error
{
- public UnauthorisedError(string message)
+ public UnauthorisedError(string message)
: base(message, OcelotErrorCode.UnauthorizedError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Authorisation/UserDoesNotHaveClaimError.cs b/src/Ocelot/Authorisation/UserDoesNotHaveClaimError.cs
index 4752fdef..2cf8211d 100644
--- a/src/Ocelot/Authorisation/UserDoesNotHaveClaimError.cs
+++ b/src/Ocelot/Authorisation/UserDoesNotHaveClaimError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Authorisation
{
public class UserDoesNotHaveClaimError : Error
{
- public UserDoesNotHaveClaimError(string message)
+ public UserDoesNotHaveClaimError(string message)
: base(message, OcelotErrorCode.UserDoesNotHaveClaimError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Cache/CacheKeyGenerator.cs b/src/Ocelot/Cache/CacheKeyGenerator.cs
index c33c6104..29b2174b 100644
--- a/src/Ocelot/Cache/CacheKeyGenerator.cs
+++ b/src/Ocelot/Cache/CacheKeyGenerator.cs
@@ -1,13 +1,17 @@
-using System.Text;
+using Ocelot.Middleware;
+using System.Text;
using System.Threading.Tasks;
-using Ocelot.Middleware;
-namespace Ocelot.Cache {
- public class CacheKeyGenerator : ICacheKeyGenerator {
- public string GenerateRequestCacheKey(DownstreamContext context) {
+namespace Ocelot.Cache
+{
+ public class CacheKeyGenerator : ICacheKeyGenerator
+ {
+ public string GenerateRequestCacheKey(DownstreamContext context)
+ {
string hashedContent = null;
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;
downStreamUrlKeyBuilder.Append(requestContentString);
}
diff --git a/src/Ocelot/Cache/CacheObject.cs b/src/Ocelot/Cache/CacheObject.cs
index adee3ed8..ef310a06 100644
--- a/src/Ocelot/Cache/CacheObject.cs
+++ b/src/Ocelot/Cache/CacheObject.cs
@@ -2,7 +2,7 @@
{
using System;
- class CacheObject
+ internal class CacheObject
{
public CacheObject(T value, DateTime expires)
{
diff --git a/src/Ocelot/Cache/CachedResponse.cs b/src/Ocelot/Cache/CachedResponse.cs
index 538a4c35..aa2fafcc 100644
--- a/src/Ocelot/Cache/CachedResponse.cs
+++ b/src/Ocelot/Cache/CachedResponse.cs
@@ -27,7 +27,7 @@ namespace Ocelot.Cache
public Dictionary> ContentHeaders { get; private set; }
public string Body { get; private set; }
-
+
public string ReasonPhrase { get; private set; }
}
}
diff --git a/src/Ocelot/Cache/ICacheKeyGenerator.cs b/src/Ocelot/Cache/ICacheKeyGenerator.cs
index 5a65eb8a..fc6ad52b 100644
--- a/src/Ocelot/Cache/ICacheKeyGenerator.cs
+++ b/src/Ocelot/Cache/ICacheKeyGenerator.cs
@@ -1,7 +1,9 @@
using Ocelot.Middleware;
-namespace Ocelot.Cache {
- public interface ICacheKeyGenerator {
+namespace Ocelot.Cache
+{
+ public interface ICacheKeyGenerator
+ {
string GenerateRequestCacheKey(DownstreamContext context);
}
}
diff --git a/src/Ocelot/Cache/IOcelotCache.cs b/src/Ocelot/Cache/IOcelotCache.cs
index 04ac2b51..8d507489 100644
--- a/src/Ocelot/Cache/IOcelotCache.cs
+++ b/src/Ocelot/Cache/IOcelotCache.cs
@@ -5,8 +5,11 @@ namespace Ocelot.Cache
public interface IOcelotCache
{
void Add(string key, T value, TimeSpan ttl, string region);
+
T Get(string key, string region);
+
void ClearRegion(string region);
+
void AddAndDelete(string key, T value, TimeSpan ttl, string region);
}
}
diff --git a/src/Ocelot/Cache/InMemoryCache.cs b/src/Ocelot/Cache/InMemoryCache.cs
index 64c1dbc5..c0c892ad 100644
--- a/src/Ocelot/Cache/InMemoryCache.cs
+++ b/src/Ocelot/Cache/InMemoryCache.cs
@@ -35,7 +35,7 @@
}
else
{
- _regions.Add(region, new List{ key });
+ _regions.Add(region, new List { key });
}
}
diff --git a/src/Ocelot/Cache/MD5Helper.cs b/src/Ocelot/Cache/MD5Helper.cs
index d98bb8c5..ff8eaa30 100644
--- a/src/Ocelot/Cache/MD5Helper.cs
+++ b/src/Ocelot/Cache/MD5Helper.cs
@@ -1,20 +1,25 @@
using System.Security.Cryptography;
using System.Text;
-namespace Ocelot.Cache {
- public static class MD5Helper {
- public static string GenerateMd5(byte[] contentBytes) {
+namespace Ocelot.Cache
+{
+ public static class MD5Helper
+ {
+ public static string GenerateMd5(byte[] contentBytes)
+ {
MD5 md5 = MD5.Create();
byte[] hash = md5.ComputeHash(contentBytes);
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"));
}
return sb.ToString();
}
- public static string GenerateMd5(string contentString) {
+ public static string GenerateMd5(string contentString)
+ {
byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
return GenerateMd5(contentBytes);
}
diff --git a/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs b/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs
index 925e90c6..3d37febc 100644
--- a/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs
+++ b/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs
@@ -1,13 +1,13 @@
namespace Ocelot.Cache.Middleware
{
- using System;
- using System.Linq;
- using System.Net.Http;
- using System.Threading.Tasks;
using Ocelot.Logging;
using Ocelot.Middleware;
+ using System;
using System.IO;
+ using System.Linq;
+ using System.Net.Http;
using System.Text;
+ using System.Threading.Tasks;
public class OutputCacheMiddleware : OcelotMiddleware
{
@@ -19,7 +19,7 @@
IOcelotLoggerFactory loggerFactory,
IOcelotCache outputCache,
ICacheKeyGenerator cacheGeneratot)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_outputCache = outputCache;
@@ -71,12 +71,26 @@
Logger.LogDebug($"finished response added to cache for {downstreamUrlKey}");
}
- private void SetHttpResponseMessageThisRequest(DownstreamContext context,
+ private void SetHttpResponseMessageThisRequest(DownstreamContext context,
DownstreamResponse response)
{
context.DownstreamResponse = response;
}
+ private string GenerateRequestCacheKey(DownstreamContext context)
+ {
+ string hashedContent = null;
+ StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{context.DownstreamRequest.Method}-{context.DownstreamRequest.OriginalString}");
+ if (context.DownstreamRequest.Content != null)
+ {
+ string requestContentString = Task.Run(async () => await context.DownstreamRequest.Content?.ReadAsStringAsync()).Result;
+ downStreamUrlKeyBuilder.Append(requestContentString);
+ }
+
+ hashedContent = MD5Helper.GenerateMd5(downStreamUrlKeyBuilder.ToString());
+ return hashedContent;
+ }
+
internal DownstreamResponse CreateHttpResponseMessage(CachedResponse cached)
{
if (cached == null)
diff --git a/src/Ocelot/Cache/Middleware/OutputCacheMiddlewareExtensions.cs b/src/Ocelot/Cache/Middleware/OutputCacheMiddlewareExtensions.cs
index e28df6f0..fa80a237 100644
--- a/src/Ocelot/Cache/Middleware/OutputCacheMiddlewareExtensions.cs
+++ b/src/Ocelot/Cache/Middleware/OutputCacheMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Cache.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Cache/OutputCacheController.cs b/src/Ocelot/Cache/OutputCacheController.cs
index cc33e8aa..3564e393 100644
--- a/src/Ocelot/Cache/OutputCacheController.cs
+++ b/src/Ocelot/Cache/OutputCacheController.cs
@@ -22,4 +22,4 @@ namespace Ocelot.Cache
return new NoContentResult();
}
}
-}
+}
diff --git a/src/Ocelot/Cache/RegionCreator.cs b/src/Ocelot/Cache/RegionCreator.cs
index f5a94c21..cc1a9359 100644
--- a/src/Ocelot/Cache/RegionCreator.cs
+++ b/src/Ocelot/Cache/RegionCreator.cs
@@ -1,6 +1,5 @@
-using System.Linq;
-using Ocelot.Configuration;
using Ocelot.Configuration.File;
+using System.Linq;
namespace Ocelot.Cache
{
@@ -8,16 +7,16 @@ namespace Ocelot.Cache
{
public string Create(FileReRoute reRoute)
{
- if(!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
+ if (!string.IsNullOrEmpty(reRoute?.FileCacheOptions?.Region))
{
return reRoute?.FileCacheOptions?.Region;
}
var methods = string.Join("", reRoute.UpstreamHttpMethod.Select(m => m));
- var region = $"{methods}{reRoute.UpstreamPathTemplate.Replace("/", "")}";
-
+ var region = $"{methods}{reRoute.UpstreamPathTemplate.Replace("/", "")}";
+
return region;
}
}
-}
+}
diff --git a/src/Ocelot/Cache/Regions.cs b/src/Ocelot/Cache/Regions.cs
index 2ef0f6a8..05f254cb 100644
--- a/src/Ocelot/Cache/Regions.cs
+++ b/src/Ocelot/Cache/Regions.cs
@@ -11,4 +11,4 @@ namespace Ocelot.Cache
public List Value { get; }
}
-}
+}
diff --git a/src/Ocelot/Claims/AddClaimsToRequest.cs b/src/Ocelot/Claims/AddClaimsToRequest.cs
index 9ff0254f..ab197c2b 100644
--- a/src/Ocelot/Claims/AddClaimsToRequest.cs
+++ b/src/Ocelot/Claims/AddClaimsToRequest.cs
@@ -1,10 +1,10 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Claims;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Responses;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
namespace Ocelot.Claims
{
diff --git a/src/Ocelot/Claims/IAddClaimsToRequest.cs b/src/Ocelot/Claims/IAddClaimsToRequest.cs
index 9adbcab4..b9db39f5 100644
--- a/src/Ocelot/Claims/IAddClaimsToRequest.cs
+++ b/src/Ocelot/Claims/IAddClaimsToRequest.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.Claims
{
@@ -10,4 +10,4 @@ namespace Ocelot.Claims
Response SetClaimsOnContext(List claimsToThings,
HttpContext context);
}
-}
+}
diff --git a/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs b/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
index 7e1a301e..58838a97 100644
--- a/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
+++ b/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
@@ -1,10 +1,7 @@
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-using Ocelot.DownstreamRouteFinder.Middleware;
-using Ocelot.Infrastructure.RequestData;
-using Ocelot.Logging;
+using Ocelot.Logging;
using Ocelot.Middleware;
+using System.Linq;
+using System.Threading.Tasks;
namespace Ocelot.Claims.Middleware
{
@@ -13,10 +10,10 @@ namespace Ocelot.Claims.Middleware
private readonly OcelotRequestDelegate _next;
private readonly IAddClaimsToRequest _addClaimsToRequest;
- public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
+ public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
- IAddClaimsToRequest addClaimsToRequest)
- :base(loggerFactory.CreateLogger())
+ IAddClaimsToRequest addClaimsToRequest)
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_addClaimsToRequest = addClaimsToRequest;
diff --git a/src/Ocelot/Configuration/AuthenticationOptions.cs b/src/Ocelot/Configuration/AuthenticationOptions.cs
index 2b911b58..9cede795 100644
--- a/src/Ocelot/Configuration/AuthenticationOptions.cs
+++ b/src/Ocelot/Configuration/AuthenticationOptions.cs
@@ -13,4 +13,4 @@ namespace Ocelot.Configuration
public List AllowedScopes { get; private set; }
public string AuthenticationProviderKey { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
index 8e2583d2..42ad17db 100644
--- a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
@@ -1,8 +1,8 @@
-using System.Collections.Generic;
-using System.Net.Http;
-using Ocelot.Values;
-using System.Linq;
using Ocelot.Configuration.Creator;
+using Ocelot.Values;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
namespace Ocelot.Configuration.Builder
{
@@ -39,6 +39,7 @@ namespace Ocelot.Configuration.Builder
private List _addHeadersToUpstream;
private bool _dangerousAcceptAnyServerCertificateValidator;
private SecurityOptions _securityOptions;
+
public DownstreamReRouteBuilder()
{
_downstreamAddresses = new List();
@@ -55,7 +56,7 @@ namespace Ocelot.Configuration.Builder
public DownstreamReRouteBuilder WithLoadBalancerOptions(LoadBalancerOptions loadBalancerOptions)
{
- _loadBalancerOptions = loadBalancerOptions;
+ _loadBalancerOptions = loadBalancerOptions;
return this;
}
@@ -142,7 +143,7 @@ namespace Ocelot.Configuration.Builder
_qosOptions = input;
return this;
}
-
+
public DownstreamReRouteBuilder WithLoadBalancerKey(string loadBalancerKey)
{
_loadBalancerKey = loadBalancerKey;
@@ -239,26 +240,26 @@ namespace Ocelot.Configuration.Builder
_key,
_upstreamTemplatePattern,
_upstreamHeaderFindAndReplace,
- _downstreamHeaderFindAndReplace,
+ _downstreamHeaderFindAndReplace,
_downstreamAddresses,
- _serviceName,
- _httpHandlerOptions,
- _useServiceDiscovery,
- _enableRateLimiting,
+ _serviceName,
+ _httpHandlerOptions,
+ _useServiceDiscovery,
+ _enableRateLimiting,
_qosOptions,
- _downstreamScheme,
- _requestIdHeaderKey,
- _isCached,
- _fileCacheOptions,
- _loadBalancerOptions,
+ _downstreamScheme,
+ _requestIdHeaderKey,
+ _isCached,
+ _fileCacheOptions,
+ _loadBalancerOptions,
_rateLimitOptions,
- _routeClaimRequirement,
- _claimToQueries,
- _claimsToHeaders,
+ _routeClaimRequirement,
+ _claimToQueries,
+ _claimsToHeaders,
_claimToClaims,
- _isAuthenticated,
- _isAuthorised,
- _authenticationOptions,
+ _isAuthenticated,
+ _isAuthorised,
+ _authenticationOptions,
new DownstreamPathTemplate(_downstreamPathTemplate),
_loadBalancerKey,
_delegatingHandlers,
diff --git a/src/Ocelot/Configuration/Builder/QoSOptionsBuilder.cs b/src/Ocelot/Configuration/Builder/QoSOptionsBuilder.cs
index e1b86d1a..413163db 100644
--- a/src/Ocelot/Configuration/Builder/QoSOptionsBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/QoSOptionsBuilder.cs
@@ -39,4 +39,4 @@
return new QoSOptions(_exceptionsAllowedBeforeBreaking, _durationOfBreak, _timeoutValue, _key);
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Builder/RateLimitOptionsBuilder.cs b/src/Ocelot/Configuration/Builder/RateLimitOptionsBuilder.cs
index 69ad913c..eba79769 100644
--- a/src/Ocelot/Configuration/Builder/RateLimitOptionsBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/RateLimitOptionsBuilder.cs
@@ -63,9 +63,9 @@ namespace Ocelot.Configuration.Builder
public RateLimitOptions Build()
{
- return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _clientWhitelist,
- _disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix,
+ return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _clientWhitelist,
+ _disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix,
_rateLimitRule, _httpStatusCode);
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs b/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs
index dae8c11e..4716c03a 100644
--- a/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Builder
{
- using System.Collections.Generic;
- using System.Net.Http;
- using Ocelot.Values;
- using System.Linq;
using Ocelot.Configuration.File;
+ using Ocelot.Values;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net.Http;
public class ReRouteBuilder
{
@@ -68,11 +68,11 @@
return new ReRoute(
_downstreamReRoutes,
_downstreamReRoutesConfig,
- _upstreamHttpMethod,
- _upstreamTemplatePattern,
+ _upstreamHttpMethod,
+ _upstreamTemplatePattern,
_upstreamHost,
_aggregator
);
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/CacheOptions.cs b/src/Ocelot/Configuration/CacheOptions.cs
index 46c49280..e5738a46 100644
--- a/src/Ocelot/Configuration/CacheOptions.cs
+++ b/src/Ocelot/Configuration/CacheOptions.cs
@@ -12,4 +12,4 @@
public string Region { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/ClaimToThing.cs b/src/Ocelot/Configuration/ClaimToThing.cs
index 0d13f5d0..9264de5f 100644
--- a/src/Ocelot/Configuration/ClaimToThing.cs
+++ b/src/Ocelot/Configuration/ClaimToThing.cs
@@ -15,4 +15,4 @@
public string Delimiter { get; private set; }
public int Index { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/AggregatesCreator.cs b/src/Ocelot/Configuration/Creator/AggregatesCreator.cs
index 9acef561..1dd8fea5 100644
--- a/src/Ocelot/Configuration/Creator/AggregatesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/AggregatesCreator.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator
{
- using System.Collections.Generic;
- using System.Linq;
using Builder;
using File;
+ using System.Collections.Generic;
+ using System.Linq;
public class AggregatesCreator : IAggregatesCreator
{
diff --git a/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs b/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs
index ce5e0e1e..69f4f49d 100644
--- a/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/AuthenticationOptionsCreator.cs
@@ -7,6 +7,6 @@ namespace Ocelot.Configuration.Creator
public AuthenticationOptions Create(FileReRoute reRoute)
{
return new AuthenticationOptions(reRoute.AuthenticationOptions.AllowedScopes, reRoute.AuthenticationOptions.AuthenticationProviderKey);
- }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Creator/ClaimsToThingCreator.cs b/src/Ocelot/Configuration/Creator/ClaimsToThingCreator.cs
index 0be61658..1500f5d3 100644
--- a/src/Ocelot/Configuration/Creator/ClaimsToThingCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ClaimsToThingCreator.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
using Ocelot.Configuration.Parser;
using Ocelot.Logging;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
@@ -14,9 +14,9 @@ namespace Ocelot.Configuration.Creator
{
_logger = loggerFactory.CreateLogger();
_claimToThingConfigParser = claimToThingConfigurationParser;
- }
-
- public List Create(Dictionary inputToBeParsed)
+ }
+
+ public List Create(Dictionary inputToBeParsed)
{
var claimsToThings = new List();
@@ -37,4 +37,4 @@ namespace Ocelot.Configuration.Creator
return claimsToThings;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Creator/ConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/ConfigurationCreator.cs
index e6fe13ac..1d5abc32 100644
--- a/src/Ocelot/Configuration/Creator/ConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ConfigurationCreator.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Creator
{
+ using DependencyInjection;
+ using File;
+ using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
- using File;
- using DependencyInjection;
- using Microsoft.Extensions.DependencyInjection;
public class ConfigurationCreator : IConfigurationCreator
{
diff --git a/src/Ocelot/Configuration/Creator/DownstreamAddressesCreator.cs b/src/Ocelot/Configuration/Creator/DownstreamAddressesCreator.cs
index 777f9dce..78718c84 100644
--- a/src/Ocelot/Configuration/Creator/DownstreamAddressesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/DownstreamAddressesCreator.cs
@@ -1,6 +1,6 @@
+using Ocelot.Configuration.File;
using System.Collections.Generic;
using System.Linq;
-using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator
{
@@ -11,4 +11,4 @@ namespace Ocelot.Configuration.Creator
return reRoute.DownstreamHostAndPorts.Select(hostAndPort => new DownstreamHostAndPort(hostAndPort.Host, hostAndPort.Port)).ToList();
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/DynamicsCreator.cs b/src/Ocelot/Configuration/Creator/DynamicsCreator.cs
index 96d56287..2b5193c0 100644
--- a/src/Ocelot/Configuration/Creator/DynamicsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/DynamicsCreator.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator
{
- using System.Collections.Generic;
- using System.Linq;
using Builder;
using File;
+ using System.Collections.Generic;
+ using System.Linq;
public class DynamicsCreator : IDynamicsCreator
{
diff --git a/src/Ocelot/Configuration/Creator/FileInternalConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/FileInternalConfigurationCreator.cs
index f59f8a80..1a12cab5 100644
--- a/src/Ocelot/Configuration/Creator/FileInternalConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/FileInternalConfigurationCreator.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Creator
{
+ using File;
+ using Responses;
using System.Linq;
using System.Threading.Tasks;
- using File;
using Validator;
- using Responses;
public class FileInternalConfigurationCreator : IInternalConfigurationCreator
{
diff --git a/src/Ocelot/Configuration/Creator/HeaderFindAndReplaceCreator.cs b/src/Ocelot/Configuration/Creator/HeaderFindAndReplaceCreator.cs
index 53f629af..fdf05450 100644
--- a/src/Ocelot/Configuration/Creator/HeaderFindAndReplaceCreator.cs
+++ b/src/Ocelot/Configuration/Creator/HeaderFindAndReplaceCreator.cs
@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
using Ocelot.Configuration.File;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging;
-using Ocelot.Middleware;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
@@ -25,7 +23,7 @@ namespace Ocelot.Configuration.Creator
var upstream = new List();
var addHeadersToUpstream = new List();
- foreach(var input in fileReRoute.UpstreamHeaderTransform)
+ foreach (var input in fileReRoute.UpstreamHeaderTransform)
{
if (input.Value.Contains(","))
{
@@ -46,14 +44,14 @@ namespace Ocelot.Configuration.Creator
}
var downstream = new List();
- var addHeadersToDownstream = new List();
-
- foreach(var input in fileReRoute.DownstreamHeaderTransform)
+ var addHeadersToDownstream = new List();
+
+ foreach (var input in fileReRoute.DownstreamHeaderTransform)
{
- if(input.Value.Contains(","))
+ if (input.Value.Contains(","))
{
var hAndr = Map(input);
- if(!hAndr.IsError)
+ if (!hAndr.IsError)
{
downstream.Add(hAndr.Data);
}
@@ -66,27 +64,27 @@ namespace Ocelot.Configuration.Creator
{
addHeadersToDownstream.Add(new AddHeader(input.Key, input.Value));
}
- }
-
+ }
+
return new HeaderTransformations(upstream, downstream, addHeadersToDownstream, addHeadersToUpstream);
}
- private Response Map(KeyValuePair input)
+ private Response Map(KeyValuePair input)
{
var findAndReplace = input.Value.Split(",");
var replace = findAndReplace[1].TrimStart();
var startOfPlaceholder = replace.IndexOf("{");
- if(startOfPlaceholder > -1)
+ if (startOfPlaceholder > -1)
{
- var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
-
+ var endOfPlaceholder = replace.IndexOf("}", startOfPlaceholder);
+
var placeholder = replace.Substring(startOfPlaceholder, startOfPlaceholder + (endOfPlaceholder + 1));
var value = _placeholders.Get(placeholder);
- if(value.IsError)
+ if (value.IsError)
{
return new ErrorResponse(value.Errors);
}
@@ -94,9 +92,9 @@ namespace Ocelot.Configuration.Creator
replace = replace.Replace(placeholder, value.Data);
}
- var hAndr = new HeaderFindAndReplace(input.Key, findAndReplace[0], replace, 0);
-
+ var hAndr = new HeaderFindAndReplace(input.Key, findAndReplace[0], replace, 0);
+
return new OkResponse(hAndr);
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/HeaderTransformations.cs b/src/Ocelot/Configuration/Creator/HeaderTransformations.cs
index 72b6e1f6..29e9c40d 100644
--- a/src/Ocelot/Configuration/Creator/HeaderTransformations.cs
+++ b/src/Ocelot/Configuration/Creator/HeaderTransformations.cs
@@ -5,7 +5,7 @@ namespace Ocelot.Configuration.Creator
public class HeaderTransformations
{
public HeaderTransformations(
- List upstream,
+ List upstream,
List downstream,
List addHeaderToDownstream,
List addHeaderToUpstream)
@@ -23,4 +23,4 @@ namespace Ocelot.Configuration.Creator
public List AddHeadersToDownstream { get; }
public List AddHeadersToUpstream { get; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/HttpHandlerOptionsCreator.cs b/src/Ocelot/Configuration/Creator/HttpHandlerOptionsCreator.cs
index f55e35ca..08e79ad1 100644
--- a/src/Ocelot/Configuration/Creator/HttpHandlerOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/HttpHandlerOptionsCreator.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Configuration.Creator
{
- using System;
using Logging;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration.File;
+ using System;
public class HttpHandlerOptionsCreator : IHttpHandlerOptionsCreator
{
@@ -16,7 +16,7 @@
public HttpHandlerOptions Create(FileHttpHandlerOptions options)
{
- var useTracing = _tracer!= null && options.UseTracing;
+ var useTracing = _tracer != null && options.UseTracing;
return new HttpHandlerOptions(options.AllowAutoRedirect,
options.UseCookieContainer, useTracing, options.UseProxy);
diff --git a/src/Ocelot/Configuration/Creator/IAggregatesCreator.cs b/src/Ocelot/Configuration/Creator/IAggregatesCreator.cs
index 1586a2be..05fe2177 100644
--- a/src/Ocelot/Configuration/Creator/IAggregatesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IAggregatesCreator.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/IAuthenticationOptionsCreator.cs b/src/Ocelot/Configuration/Creator/IAuthenticationOptionsCreator.cs
index a987f69a..95636af5 100644
--- a/src/Ocelot/Configuration/Creator/IAuthenticationOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IAuthenticationOptionsCreator.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator
@@ -7,4 +6,4 @@ namespace Ocelot.Configuration.Creator
{
AuthenticationOptions Create(FileReRoute reRoute);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Creator/IClaimsToThingCreator.cs b/src/Ocelot/Configuration/Creator/IClaimsToThingCreator.cs
index ead3d537..3f424790 100644
--- a/src/Ocelot/Configuration/Creator/IClaimsToThingCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IClaimsToThingCreator.cs
@@ -4,6 +4,6 @@ namespace Ocelot.Configuration.Creator
{
public interface IClaimsToThingCreator
{
- List Create(Dictionary thingsBeingAdded);
+ List Create(Dictionary thingsBeingAdded);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Creator/IConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/IConfigurationCreator.cs
index aed2db54..8aa42d0e 100644
--- a/src/Ocelot/Configuration/Creator/IConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IConfigurationCreator.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/IDownstreamAddressesCreator.cs b/src/Ocelot/Configuration/Creator/IDownstreamAddressesCreator.cs
index 6db1c1bf..e6081290 100644
--- a/src/Ocelot/Configuration/Creator/IDownstreamAddressesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IDownstreamAddressesCreator.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
@@ -7,4 +7,4 @@ namespace Ocelot.Configuration.Creator
{
List Create(FileReRoute reRoute);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/IDynamicsCreator.cs b/src/Ocelot/Configuration/Creator/IDynamicsCreator.cs
index f6c7e16c..715db098 100644
--- a/src/Ocelot/Configuration/Creator/IDynamicsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IDynamicsCreator.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/IHeaderFindAndReplaceCreator.cs b/src/Ocelot/Configuration/Creator/IHeaderFindAndReplaceCreator.cs
index 9a983a8a..496e17bf 100644
--- a/src/Ocelot/Configuration/Creator/IHeaderFindAndReplaceCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IHeaderFindAndReplaceCreator.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator
@@ -7,4 +6,4 @@ namespace Ocelot.Configuration.Creator
{
HeaderTransformations Create(FileReRoute fileReRoute);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/IHttpHandlerOptionsCreator.cs b/src/Ocelot/Configuration/Creator/IHttpHandlerOptionsCreator.cs
index 80137651..76a9bc94 100644
--- a/src/Ocelot/Configuration/Creator/IHttpHandlerOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IHttpHandlerOptionsCreator.cs
@@ -9,4 +9,4 @@ namespace Ocelot.Configuration.Creator
{
HttpHandlerOptions Create(FileHttpHandlerOptions fileReRoute);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/IInternalConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/IInternalConfigurationCreator.cs
index a0f3cb42..f8e39d7b 100644
--- a/src/Ocelot/Configuration/Creator/IInternalConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IInternalConfigurationCreator.cs
@@ -1,6 +1,6 @@
-using System.Threading.Tasks;
using Ocelot.Configuration.File;
using Ocelot.Responses;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/IQoSOptionsCreator.cs b/src/Ocelot/Configuration/Creator/IQoSOptionsCreator.cs
index 77ada9c6..128058a9 100644
--- a/src/Ocelot/Configuration/Creator/IQoSOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IQoSOptionsCreator.cs
@@ -1,12 +1,14 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
public interface IQoSOptionsCreator
{
QoSOptions Create(FileQoSOptions options);
+
QoSOptions Create(FileQoSOptions options, string pathTemplate, List httpMethods);
+
QoSOptions Create(QoSOptions options, string pathTemplate, List httpMethods);
}
}
diff --git a/src/Ocelot/Configuration/Creator/IReRouteOptionsCreator.cs b/src/Ocelot/Configuration/Creator/IReRouteOptionsCreator.cs
index 1f7983d6..1d5761d5 100644
--- a/src/Ocelot/Configuration/Creator/IReRouteOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IReRouteOptionsCreator.cs
@@ -6,4 +6,4 @@ namespace Ocelot.Configuration.Creator
{
ReRouteOptions Create(FileReRoute fileReRoute);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/IReRoutesCreator.cs b/src/Ocelot/Configuration/Creator/IReRoutesCreator.cs
index 608e2af5..18b26528 100644
--- a/src/Ocelot/Configuration/Creator/IReRoutesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IReRoutesCreator.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/ISecurityOptionsCreator.cs b/src/Ocelot/Configuration/Creator/ISecurityOptionsCreator.cs
index 792c8530..5f5f727f 100644
--- a/src/Ocelot/Configuration/Creator/ISecurityOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ISecurityOptionsCreator.cs
@@ -1,7 +1,4 @@
using Ocelot.Configuration.File;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/IUpstreamTemplatePatternCreator.cs b/src/Ocelot/Configuration/Creator/IUpstreamTemplatePatternCreator.cs
index b8303189..aaec7634 100644
--- a/src/Ocelot/Configuration/Creator/IUpstreamTemplatePatternCreator.cs
+++ b/src/Ocelot/Configuration/Creator/IUpstreamTemplatePatternCreator.cs
@@ -7,4 +7,4 @@ namespace Ocelot.Configuration.Creator
{
UpstreamPathTemplate Create(IReRoute reRoute);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Creator/ReRouteKeyCreator.cs b/src/Ocelot/Configuration/Creator/ReRouteKeyCreator.cs
index 4c7d276d..44be1afa 100644
--- a/src/Ocelot/Configuration/Creator/ReRouteKeyCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ReRouteKeyCreator.cs
@@ -1,6 +1,6 @@
-using System.Linq;
using Ocelot.Configuration.File;
using Ocelot.LoadBalancer.LoadBalancers;
+using System.Linq;
namespace Ocelot.Configuration.Creator
{
@@ -12,14 +12,14 @@ namespace Ocelot.Configuration.Creator
{
return $"{nameof(CookieStickySessions)}:{fileReRoute.LoadBalancerOptions.Key}";
}
-
+
return $"{fileReRoute.UpstreamPathTemplate}|{string.Join(",", fileReRoute.UpstreamHttpMethod)}|{string.Join(",", fileReRoute.DownstreamHostAndPorts.Select(x => $"{x.Host}:{x.Port}"))}";
}
private bool IsStickySession(FileReRoute fileReRoute)
{
- if (!string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Type)
- && !string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Key)
+ if (!string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Type)
+ && !string.IsNullOrEmpty(fileReRoute.LoadBalancerOptions.Key)
&& fileReRoute.LoadBalancerOptions.Type == nameof(CookieStickySessions))
{
return true;
diff --git a/src/Ocelot/Configuration/Creator/ReRouteOptionsCreator.cs b/src/Ocelot/Configuration/Creator/ReRouteOptionsCreator.cs
index 1eb4e372..ce710c8e 100644
--- a/src/Ocelot/Configuration/Creator/ReRouteOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ReRouteOptionsCreator.cs
@@ -20,7 +20,7 @@ namespace Ocelot.Configuration.Creator
.WithRateLimiting(enableRateLimiting)
.WithUseServiceDiscovery(useServiceDiscovery)
.Build();
-
+
return options;
}
diff --git a/src/Ocelot/Configuration/Creator/ReRoutesCreator.cs b/src/Ocelot/Configuration/Creator/ReRoutesCreator.cs
index d2ec6619..c6171521 100644
--- a/src/Ocelot/Configuration/Creator/ReRoutesCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ReRoutesCreator.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Creator
{
+ using Builder;
+ using Cache;
+ using File;
using System.Collections.Generic;
using System.Linq;
- using Cache;
- using Builder;
- using File;
public class ReRoutesCreator : IReRoutesCreator
{
diff --git a/src/Ocelot/Configuration/Creator/RequestIdKeyCreator.cs b/src/Ocelot/Configuration/Creator/RequestIdKeyCreator.cs
index 6fad9b28..8d4a81fe 100644
--- a/src/Ocelot/Configuration/Creator/RequestIdKeyCreator.cs
+++ b/src/Ocelot/Configuration/Creator/RequestIdKeyCreator.cs
@@ -6,13 +6,13 @@ namespace Ocelot.Configuration.Creator
{
public string Create(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
{
- var reRouteId = !string.IsNullOrEmpty(fileReRoute.RequestIdKey);
-
- var requestIdKey = reRouteId
- ? fileReRoute.RequestIdKey
- : globalConfiguration.RequestIdKey;
-
- return requestIdKey;
+ var reRouteId = !string.IsNullOrEmpty(fileReRoute.RequestIdKey);
+
+ var requestIdKey = reRouteId
+ ? fileReRoute.RequestIdKey
+ : globalConfiguration.RequestIdKey;
+
+ return requestIdKey;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Creator/SecurityOptionsCreator.cs b/src/Ocelot/Configuration/Creator/SecurityOptionsCreator.cs
index d1ee3508..cc538510 100644
--- a/src/Ocelot/Configuration/Creator/SecurityOptionsCreator.cs
+++ b/src/Ocelot/Configuration/Creator/SecurityOptionsCreator.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Ocelot.Configuration.File;
+using Ocelot.Configuration.File;
namespace Ocelot.Configuration.Creator
{
diff --git a/src/Ocelot/Configuration/Creator/ServiceProviderConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/ServiceProviderConfigurationCreator.cs
index 3b0ee225..aa631f87 100644
--- a/src/Ocelot/Configuration/Creator/ServiceProviderConfigurationCreator.cs
+++ b/src/Ocelot/Configuration/Creator/ServiceProviderConfigurationCreator.cs
@@ -9,8 +9,8 @@ namespace Ocelot.Configuration.Creator
{
var port = globalConfiguration?.ServiceDiscoveryProvider?.Port ?? 0;
var host = globalConfiguration?.ServiceDiscoveryProvider?.Host ?? "localhost";
- var type = !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Type)
- ? globalConfiguration?.ServiceDiscoveryProvider?.Type
+ var type = !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Type)
+ ? globalConfiguration?.ServiceDiscoveryProvider?.Type
: "consul";
var pollingInterval = globalConfiguration?.ServiceDiscoveryProvider?.PollingInterval ?? 0;
var k8snamespace = globalConfiguration?.ServiceDiscoveryProvider?.Namespace ?? string.Empty;
diff --git a/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs b/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs
index b5acc10f..7de660b7 100644
--- a/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs
+++ b/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
using Ocelot.Configuration.File;
using Ocelot.Values;
+using System.Collections.Generic;
namespace Ocelot.Configuration.Creator
{
@@ -29,7 +29,7 @@ namespace Ocelot.Configuration.Creator
placeholders.Add(placeHolderName);
//hack to handle /{url} case
- if(ForwardSlashAndOnePlaceHolder(upstreamTemplate, placeholders, postitionOfPlaceHolderClosingBracket))
+ if (ForwardSlashAndOnePlaceHolder(upstreamTemplate, placeholders, postitionOfPlaceHolderClosingBracket))
{
return new UpstreamPathTemplate(RegExForwardSlashAndOnePlaceHolder, 0, false, reRoute.UpstreamPathTemplate);
}
@@ -48,11 +48,11 @@ namespace Ocelot.Configuration.Creator
{
var indexOfPlaceholder = upstreamTemplate.IndexOf(placeholders[i]);
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);
- }
- else
+ }
+ else
{
upstreamTemplate = upstreamTemplate.Replace(placeholders[i], RegExMatchOneOrMoreOfEverythingUntilNextForwardSlash);
}
@@ -63,13 +63,13 @@ namespace Ocelot.Configuration.Creator
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
- ? $"^{upstreamTemplate}{RegExMatchEndString}"
+ var route = reRoute.ReRouteIsCaseSensitive
+ ? $"^{upstreamTemplate}{RegExMatchEndString}"
: $"^{RegExIgnoreCase}{upstreamTemplate}{RegExMatchEndString}";
return new UpstreamPathTemplate(route, reRoute.Priority, containsQueryString, reRoute.UpstreamPathTemplate);
@@ -77,8 +77,8 @@ namespace Ocelot.Configuration.Creator
private bool ForwardSlashAndOnePlaceHolder(string upstreamTemplate, List 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;
}
diff --git a/src/Ocelot/Configuration/DownstreamHostAndPort.cs b/src/Ocelot/Configuration/DownstreamHostAndPort.cs
index 186cce2f..672a8b9c 100644
--- a/src/Ocelot/Configuration/DownstreamHostAndPort.cs
+++ b/src/Ocelot/Configuration/DownstreamHostAndPort.cs
@@ -11,4 +11,4 @@
public string Host { get; private set; }
public int Port { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/DownstreamReRoute.cs b/src/Ocelot/Configuration/DownstreamReRoute.cs
index b8ec926c..b332b622 100644
--- a/src/Ocelot/Configuration/DownstreamReRoute.cs
+++ b/src/Ocelot/Configuration/DownstreamReRoute.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Configuration
{
- using System.Collections.Generic;
using Creator;
+ using System.Collections.Generic;
using Values;
public class DownstreamReRoute
diff --git a/src/Ocelot/Configuration/File/AggregateReRouteConfig.cs b/src/Ocelot/Configuration/File/AggregateReRouteConfig.cs
index 8a155c1b..6519d6b5 100644
--- a/src/Ocelot/Configuration/File/AggregateReRouteConfig.cs
+++ b/src/Ocelot/Configuration/File/AggregateReRouteConfig.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Ocelot.Configuration.File
+namespace Ocelot.Configuration.File
{
public class AggregateReRouteConfig
{
diff --git a/src/Ocelot/Configuration/File/FileAggregateReRoute.cs b/src/Ocelot/Configuration/File/FileAggregateReRoute.cs
index 5c3b551c..2f1b4676 100644
--- a/src/Ocelot/Configuration/File/FileAggregateReRoute.cs
+++ b/src/Ocelot/Configuration/File/FileAggregateReRoute.cs
@@ -4,19 +4,19 @@ namespace Ocelot.Configuration.File
{
public class FileAggregateReRoute : IReRoute
{
- public List ReRouteKeys { get;set; }
- public List ReRouteKeysConfig { get;set; }
- public string UpstreamPathTemplate { get;set; }
+ public List ReRouteKeys { get; set; }
+ public List ReRouteKeysConfig { get; set; }
+ public string UpstreamPathTemplate { get; set; }
public string UpstreamHost { get; set; }
public bool ReRouteIsCaseSensitive { get; set; }
public string Aggregator { get; set; }
// Only supports GET..are you crazy!! POST, PUT WOULD BE CRAZY!! :)
- public List UpstreamHttpMethod
- {
- get { return new List {"Get"}; }
+ public List UpstreamHttpMethod
+ {
+ get { return new List { "Get" }; }
}
- public int Priority {get;set;} = 1;
- }
+ public int Priority { get; set; } = 1;
+ }
}
diff --git a/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs b/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
index 873d1b5b..81805df1 100644
--- a/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
+++ b/src/Ocelot/Configuration/File/FileAuthenticationOptions.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using Ocelot.Infrastructure.Extensions;
+using System.Collections.Generic;
using System.Text;
-using Ocelot.Infrastructure.Extensions;
namespace Ocelot.Configuration.File
{
@@ -11,7 +11,7 @@ namespace Ocelot.Configuration.File
AllowedScopes = new List();
}
- public string AuthenticationProviderKey {get; set;}
+ public string AuthenticationProviderKey { get; set; }
public List AllowedScopes { get; set; }
public override string ToString()
@@ -23,4 +23,4 @@ namespace Ocelot.Configuration.File
return sb.ToString();
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/File/FileCacheOptions.cs b/src/Ocelot/Configuration/File/FileCacheOptions.cs
index 9bca1f5b..b5168b3c 100644
--- a/src/Ocelot/Configuration/File/FileCacheOptions.cs
+++ b/src/Ocelot/Configuration/File/FileCacheOptions.cs
@@ -3,6 +3,6 @@
public class FileCacheOptions
{
public int TtlSeconds { get; set; }
- public string Region {get; set;}
+ public string Region { get; set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/File/FileConfiguration.cs b/src/Ocelot/Configuration/File/FileConfiguration.cs
index 49eb0c9e..ecd41a35 100644
--- a/src/Ocelot/Configuration/File/FileConfiguration.cs
+++ b/src/Ocelot/Configuration/File/FileConfiguration.cs
@@ -14,9 +14,10 @@ namespace Ocelot.Configuration.File
public List ReRoutes { get; set; }
public List DynamicReRoutes { get; set; }
-
+
// Seperate field for aggregates because this let's you re-use ReRoutes in multiple Aggregates
- public List Aggregates { get;set; }
+ public List Aggregates { get; set; }
+
public FileGlobalConfiguration GlobalConfiguration { get; set; }
}
}
diff --git a/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs b/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs
index a13284ad..9844c15d 100644
--- a/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs
+++ b/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs
@@ -13,13 +13,13 @@
public string RequestIdKey { get; set; }
- public FileServiceDiscoveryProvider ServiceDiscoveryProvider { get;set; }
+ public FileServiceDiscoveryProvider ServiceDiscoveryProvider { get; set; }
public FileRateLimitOptions RateLimitOptions { get; set; }
public FileQoSOptions QoSOptions { get; set; }
- public string BaseUrl { get ;set; }
+ public string BaseUrl { get; set; }
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
diff --git a/src/Ocelot/Configuration/File/FileHostAndPort.cs b/src/Ocelot/Configuration/File/FileHostAndPort.cs
index 67191873..23c745e0 100644
--- a/src/Ocelot/Configuration/File/FileHostAndPort.cs
+++ b/src/Ocelot/Configuration/File/FileHostAndPort.cs
@@ -2,7 +2,7 @@ namespace Ocelot.Configuration.File
{
public class FileHostAndPort
{
- public string Host {get;set;}
+ public string Host { get; set; }
public int Port { get; set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/File/FileHttpHandlerOptions.cs b/src/Ocelot/Configuration/File/FileHttpHandlerOptions.cs
index e10e7345..d765af58 100644
--- a/src/Ocelot/Configuration/File/FileHttpHandlerOptions.cs
+++ b/src/Ocelot/Configuration/File/FileHttpHandlerOptions.cs
@@ -17,4 +17,4 @@
public bool UseProxy { get; set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/File/FileLoadBalancerOptions.cs b/src/Ocelot/Configuration/File/FileLoadBalancerOptions.cs
index 29acb5f6..105ccc7a 100644
--- a/src/Ocelot/Configuration/File/FileLoadBalancerOptions.cs
+++ b/src/Ocelot/Configuration/File/FileLoadBalancerOptions.cs
@@ -4,6 +4,6 @@ namespace Ocelot.Configuration.File
{
public string Type { get; set; }
public string Key { get; set; }
- public int Expiry { get; set; }
+ public int Expiry { get; set; }
}
}
diff --git a/src/Ocelot/Configuration/File/FileQoSOptions.cs b/src/Ocelot/Configuration/File/FileQoSOptions.cs
index aa842ced..4e12b4a3 100644
--- a/src/Ocelot/Configuration/File/FileQoSOptions.cs
+++ b/src/Ocelot/Configuration/File/FileQoSOptions.cs
@@ -8,4 +8,4 @@
public int TimeoutValue { get; set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/File/FileRateLimitOptions.cs b/src/Ocelot/Configuration/File/FileRateLimitOptions.cs
index 05c6fac4..51be9ed0 100644
--- a/src/Ocelot/Configuration/File/FileRateLimitOptions.cs
+++ b/src/Ocelot/Configuration/File/FileRateLimitOptions.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Ocelot.Configuration.File
+namespace Ocelot.Configuration.File
{
public class FileRateLimitOptions
{
@@ -14,7 +9,7 @@ namespace Ocelot.Configuration.File
///
/// Gets or sets a value that will be used as a formatter for the QuotaExceeded response message.
- /// If none specified the default will be:
+ /// If none specified the default will be:
/// API calls quota exceeded! maximum admitted {0} per {1}
///
public string QuotaExceededMessage { get; set; }
@@ -32,6 +27,6 @@ namespace Ocelot.Configuration.File
///
/// Gets or sets the HTTP Status code returned when rate limiting occurs, by default value is set to 429 (Too Many Requests)
///
- public int HttpStatusCode { get; set; } = 429;
+ public int HttpStatusCode { get; set; } = 429;
}
}
diff --git a/src/Ocelot/Configuration/File/FileRateLimitRule.cs b/src/Ocelot/Configuration/File/FileRateLimitRule.cs
index 2714be4d..575ad190 100644
--- a/src/Ocelot/Configuration/File/FileRateLimitRule.cs
+++ b/src/Ocelot/Configuration/File/FileRateLimitRule.cs
@@ -1,9 +1,6 @@
-using System;
+using Ocelot.Infrastructure.Extensions;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
-using Ocelot.Infrastructure.Extensions;
namespace Ocelot.Configuration.File
{
diff --git a/src/Ocelot/Configuration/File/FileReRoute.cs b/src/Ocelot/Configuration/File/FileReRoute.cs
index 1a8f2a1a..c87bf435 100644
--- a/src/Ocelot/Configuration/File/FileReRoute.cs
+++ b/src/Ocelot/Configuration/File/FileReRoute.cs
@@ -38,17 +38,17 @@ namespace Ocelot.Configuration.File
public FileCacheOptions FileCacheOptions { get; set; }
public bool ReRouteIsCaseSensitive { get; set; }
public string ServiceName { get; set; }
- public string DownstreamScheme {get;set;}
+ public string DownstreamScheme { get; set; }
public FileQoSOptions QoSOptions { get; set; }
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
public FileRateLimitRule RateLimitOptions { get; set; }
public FileAuthenticationOptions AuthenticationOptions { get; set; }
public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
- public List DownstreamHostAndPorts {get;set;}
+ public List DownstreamHostAndPorts { get; set; }
public string UpstreamHost { get; set; }
- public string Key { get;set; }
- public List DelegatingHandlers {get;set;}
- public int Priority { get;set; }
+ public string Key { get; set; }
+ public List DelegatingHandlers { get; set; }
+ public int Priority { get; set; }
public int Timeout { get; set; }
public bool DangerousAcceptAnyServerCertificateValidator { get; set; }
public FileSecurityOptions SecurityOptions { get; set; }
diff --git a/src/Ocelot/Configuration/File/FileSecurityOptions.cs b/src/Ocelot/Configuration/File/FileSecurityOptions.cs
index 1f383a5b..c3687d48 100644
--- a/src/Ocelot/Configuration/File/FileSecurityOptions.cs
+++ b/src/Ocelot/Configuration/File/FileSecurityOptions.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
namespace Ocelot.Configuration.File
{
@@ -12,7 +10,7 @@ namespace Ocelot.Configuration.File
IPBlockedList = new List();
}
- public List IPAllowedList { get; set; }
+ public List IPAllowedList { get; set; }
public List IPBlockedList { get; set; }
}
diff --git a/src/Ocelot/Configuration/File/FileServiceDiscoveryProvider.cs b/src/Ocelot/Configuration/File/FileServiceDiscoveryProvider.cs
index 153145bd..c41f1e24 100644
--- a/src/Ocelot/Configuration/File/FileServiceDiscoveryProvider.cs
+++ b/src/Ocelot/Configuration/File/FileServiceDiscoveryProvider.cs
@@ -2,7 +2,7 @@ namespace Ocelot.Configuration.File
{
public class FileServiceDiscoveryProvider
{
- public string Host {get;set;}
+ public string Host { get; set; }
public int Port { get; set; }
public string Type { get; set; }
public string Token { get; set; }
diff --git a/src/Ocelot/Configuration/File/IReRoute.cs b/src/Ocelot/Configuration/File/IReRoute.cs
index fb7e9313..b5191428 100644
--- a/src/Ocelot/Configuration/File/IReRoute.cs
+++ b/src/Ocelot/Configuration/File/IReRoute.cs
@@ -4,6 +4,6 @@
{
string UpstreamPathTemplate { get; set; }
bool ReRouteIsCaseSensitive { get; set; }
- int Priority {get;set;}
+ int Priority { get; set; }
}
}
diff --git a/src/Ocelot/Configuration/FileConfigurationController.cs b/src/Ocelot/Configuration/FileConfigurationController.cs
index 91777ef3..2f6a51af 100644
--- a/src/Ocelot/Configuration/FileConfigurationController.cs
+++ b/src/Ocelot/Configuration/FileConfigurationController.cs
@@ -1,9 +1,9 @@
-using System;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Setter;
+using System;
+using System.Threading.Tasks;
namespace Ocelot.Configuration
{
@@ -29,7 +29,7 @@ namespace Ocelot.Configuration
{
var response = await _repo.Get();
- if(response.IsError)
+ if (response.IsError)
{
return new BadRequestObjectResult(response.Errors);
}
@@ -51,7 +51,7 @@ namespace Ocelot.Configuration
return new OkObjectResult(fileConfiguration);
}
- catch(Exception e)
+ catch (Exception e)
{
return new BadRequestObjectResult($"{e.Message}:{e.StackTrace}");
}
diff --git a/src/Ocelot/Configuration/HeaderFindAndReplace.cs b/src/Ocelot/Configuration/HeaderFindAndReplace.cs
index 6b1636c2..73966cf1 100644
--- a/src/Ocelot/Configuration/HeaderFindAndReplace.cs
+++ b/src/Ocelot/Configuration/HeaderFindAndReplace.cs
@@ -10,11 +10,11 @@ namespace Ocelot.Configuration
Index = index;
}
- public string Key {get;}
- public string Find {get;}
- public string Replace {get;}
-
- // only index 0 for now..
- public int Index {get;}
+ public string Key { get; }
+ public string Find { get; }
+ public string Replace { get; }
+
+ // only index 0 for now..
+ public int Index { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/HttpHandlerOptions.cs b/src/Ocelot/Configuration/HttpHandlerOptions.cs
index c8f88aa5..b551287f 100644
--- a/src/Ocelot/Configuration/HttpHandlerOptions.cs
+++ b/src/Ocelot/Configuration/HttpHandlerOptions.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Configuration
{
///
- /// Describes configuration parameters for http handler,
+ /// Describes configuration parameters for http handler,
/// that is created to handle a request to service
///
public class HttpHandlerOptions
@@ -34,4 +34,4 @@
///
public bool UseProxy { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/IInternalConfiguration.cs b/src/Ocelot/Configuration/IInternalConfiguration.cs
index 253f7ffc..1780da33 100644
--- a/src/Ocelot/Configuration/IInternalConfiguration.cs
+++ b/src/Ocelot/Configuration/IInternalConfiguration.cs
@@ -6,11 +6,11 @@ namespace Ocelot.Configuration
{
List ReRoutes { get; }
- string AdministrationPath {get;}
+ string AdministrationPath { get; }
- ServiceProviderConfiguration ServiceProviderConfiguration {get;}
+ ServiceProviderConfiguration ServiceProviderConfiguration { get; }
- string RequestId {get;}
+ string RequestId { get; }
LoadBalancerOptions LoadBalancerOptions { get; }
diff --git a/src/Ocelot/Configuration/InternalConfiguration.cs b/src/Ocelot/Configuration/InternalConfiguration.cs
index cd939a86..7b7649e4 100644
--- a/src/Ocelot/Configuration/InternalConfiguration.cs
+++ b/src/Ocelot/Configuration/InternalConfiguration.cs
@@ -5,13 +5,13 @@ namespace Ocelot.Configuration
public class InternalConfiguration : IInternalConfiguration
{
public InternalConfiguration(
- List reRoutes,
- string administrationPath,
- ServiceProviderConfiguration serviceProviderConfiguration,
- string requestId,
- LoadBalancerOptions loadBalancerOptions,
- string downstreamScheme,
- QoSOptions qoSOptions,
+ List reRoutes,
+ string administrationPath,
+ ServiceProviderConfiguration serviceProviderConfiguration,
+ string requestId,
+ LoadBalancerOptions loadBalancerOptions,
+ string downstreamScheme,
+ QoSOptions qoSOptions,
HttpHandlerOptions httpHandlerOptions)
{
ReRoutes = reRoutes;
@@ -25,9 +25,9 @@ namespace Ocelot.Configuration
}
public List ReRoutes { get; }
- public string AdministrationPath {get;}
- public ServiceProviderConfiguration ServiceProviderConfiguration {get;}
- public string RequestId {get;}
+ public string AdministrationPath { get; }
+ public ServiceProviderConfiguration ServiceProviderConfiguration { get; }
+ public string RequestId { get; }
public LoadBalancerOptions LoadBalancerOptions { get; }
public string DownstreamScheme { get; }
public QoSOptions QoSOptions { get; }
diff --git a/src/Ocelot/Configuration/Parser/ClaimToThingConfigurationParser.cs b/src/Ocelot/Configuration/Parser/ClaimToThingConfigurationParser.cs
index 94df168f..76614f96 100644
--- a/src/Ocelot/Configuration/Parser/ClaimToThingConfigurationParser.cs
+++ b/src/Ocelot/Configuration/Parser/ClaimToThingConfigurationParser.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Collections.Generic;
+using Ocelot.Responses;
+using System;
using System.Text.RegularExpressions;
-using Ocelot.Errors;
-using Ocelot.Responses;
namespace Ocelot.Configuration.Parser
{
@@ -58,4 +56,4 @@ namespace Ocelot.Configuration.Parser
return claimKey;
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Parser/InstructionNotForClaimsError.cs b/src/Ocelot/Configuration/Parser/InstructionNotForClaimsError.cs
index 50dd8820..24535653 100644
--- a/src/Ocelot/Configuration/Parser/InstructionNotForClaimsError.cs
+++ b/src/Ocelot/Configuration/Parser/InstructionNotForClaimsError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Configuration.Parser
{
public class InstructionNotForClaimsError : Error
{
- public InstructionNotForClaimsError()
+ public InstructionNotForClaimsError()
: base("instructions did not contain claims, at the moment we only support claims extraction", OcelotErrorCode.InstructionNotForClaimsError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Parser/NoInstructionsError.cs b/src/Ocelot/Configuration/Parser/NoInstructionsError.cs
index 8c7eafc7..67bcd3e1 100644
--- a/src/Ocelot/Configuration/Parser/NoInstructionsError.cs
+++ b/src/Ocelot/Configuration/Parser/NoInstructionsError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Configuration.Parser
{
public class NoInstructionsError : Error
{
- public NoInstructionsError(string splitToken)
+ public NoInstructionsError(string splitToken)
: base($"There we no instructions splitting on {splitToken}", OcelotErrorCode.NoInstructionsError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Parser/ParsingConfigurationHeaderError.cs b/src/Ocelot/Configuration/Parser/ParsingConfigurationHeaderError.cs
index 1f3eb627..fba6a6db 100644
--- a/src/Ocelot/Configuration/Parser/ParsingConfigurationHeaderError.cs
+++ b/src/Ocelot/Configuration/Parser/ParsingConfigurationHeaderError.cs
@@ -1,13 +1,13 @@
-using System;
-using Ocelot.Errors;
+using Ocelot.Errors;
+using System;
namespace Ocelot.Configuration.Parser
{
public class ParsingConfigurationHeaderError : Error
{
- public ParsingConfigurationHeaderError(Exception exception)
+ public ParsingConfigurationHeaderError(Exception exception)
: base($"error parsing configuration eception is {exception.Message}", OcelotErrorCode.ParsingConfigurationHeaderError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/QoSOptions.cs b/src/Ocelot/Configuration/QoSOptions.cs
index 83309c27..461ff292 100644
--- a/src/Ocelot/Configuration/QoSOptions.cs
+++ b/src/Ocelot/Configuration/QoSOptions.cs
@@ -3,9 +3,9 @@
public class QoSOptions
{
public QoSOptions(
- int exceptionsAllowedBeforeBreaking,
- int durationofBreak,
- int timeoutValue,
+ int exceptionsAllowedBeforeBreaking,
+ int durationofBreak,
+ int timeoutValue,
string key,
string timeoutStrategy = "Pessimistic")
{
@@ -14,7 +14,7 @@
TimeoutValue = timeoutValue;
TimeoutStrategy = timeoutStrategy;
Key = key;
- }
+ }
public int ExceptionsAllowedBeforeBreaking { get; }
diff --git a/src/Ocelot/Configuration/RateLimitOptions.cs b/src/Ocelot/Configuration/RateLimitOptions.cs
index 722af4cd..db1da8eb 100644
--- a/src/Ocelot/Configuration/RateLimitOptions.cs
+++ b/src/Ocelot/Configuration/RateLimitOptions.cs
@@ -1,6 +1,4 @@
using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.Configuration
{
@@ -9,12 +7,12 @@ namespace Ocelot.Configuration
///
public class RateLimitOptions
{
- public RateLimitOptions(bool enbleRateLimiting, string clientIdHeader, List clientWhitelist,bool disableRateLimitHeaders,
+ public RateLimitOptions(bool enbleRateLimiting, string clientIdHeader, List clientWhitelist, bool disableRateLimitHeaders,
string quotaExceededMessage, string rateLimitCounterPrefix, RateLimitRule rateLimitRule, int httpStatusCode)
{
EnableRateLimiting = enbleRateLimiting;
ClientIdHeader = clientIdHeader;
- ClientWhitelist = clientWhitelist?? new List();
+ ClientWhitelist = clientWhitelist ?? new List();
DisableRateLimitHeaders = disableRateLimitHeaders;
QuotaExceededMessage = quotaExceededMessage;
RateLimitCounterPrefix = rateLimitCounterPrefix;
@@ -22,23 +20,23 @@ namespace Ocelot.Configuration
HttpStatusCode = httpStatusCode;
}
- public RateLimitRule RateLimitRule { get; private set; }
+ public RateLimitRule RateLimitRule { get; private set; }
public List ClientWhitelist { get; private set; }
///
/// Gets or sets the HTTP header that holds the client identifier, by default is X-ClientId
///
- public string ClientIdHeader { get; private set; }
-
+ public string ClientIdHeader { get; private set; }
+
///
/// Gets or sets the HTTP Status code returned when rate limiting occurs, by default value is set to 429 (Too Many Requests)
///
- public int HttpStatusCode { get; private set; }
-
+ public int HttpStatusCode { get; private set; }
+
///
/// Gets or sets a value that will be used as a formatter for the QuotaExceeded response message.
- /// If none specified the default will be:
+ /// If none specified the default will be:
/// API calls quota exceeded! maximum admitted {0} per {1}
///
public string QuotaExceededMessage { get; private set; }
@@ -46,8 +44,8 @@ namespace Ocelot.Configuration
///
/// Gets or sets the counter prefix, used to compose the rate limit counter cache key
///
- public string RateLimitCounterPrefix { get; private set; }
-
+ public string RateLimitCounterPrefix { get; private set; }
+
///
/// Enables endpoint rate limiting based URL path and HTTP verb
///
@@ -58,4 +56,4 @@ namespace Ocelot.Configuration
///
public bool DisableRateLimitHeaders { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/RateLimitRule.cs b/src/Ocelot/Configuration/RateLimitRule.cs
index 9240087c..b3393ae5 100644
--- a/src/Ocelot/Configuration/RateLimitRule.cs
+++ b/src/Ocelot/Configuration/RateLimitRule.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace Ocelot.Configuration
+namespace Ocelot.Configuration
{
public class RateLimitRule
{
@@ -16,11 +14,11 @@ namespace Ocelot.Configuration
///
public string Period { get; private set; }
- public double PeriodTimespan { get; private set; }
-
+ public double PeriodTimespan { get; private set; }
+
///
/// Maximum number of requests that a client can make in a defined period
///
public long Limit { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/ReRoute.cs b/src/Ocelot/Configuration/ReRoute.cs
index 31392770..e7efe12b 100644
--- a/src/Ocelot/Configuration/ReRoute.cs
+++ b/src/Ocelot/Configuration/ReRoute.cs
@@ -1,16 +1,16 @@
namespace Ocelot.Configuration
{
- using System.Collections.Generic;
- using System.Net.Http;
using Ocelot.Configuration.File;
using Ocelot.Values;
+ using System.Collections.Generic;
+ using System.Net.Http;
public class ReRoute
{
public ReRoute(List downstreamReRoute,
List downstreamReRouteConfig,
- List upstreamHttpMethod,
- UpstreamPathTemplate upstreamTemplatePattern,
+ List upstreamHttpMethod,
+ UpstreamPathTemplate upstreamTemplatePattern,
string upstreamHost,
string aggregator)
{
@@ -27,6 +27,6 @@
public string UpstreamHost { get; private set; }
public List DownstreamReRoute { get; private set; }
public List DownstreamReRouteConfig { get; private set; }
- public string Aggregator {get; private set;}
+ public string Aggregator { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPollerOption.cs b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPollerOption.cs
new file mode 100644
index 00000000..a324a3fb
--- /dev/null
+++ b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPollerOption.cs
@@ -0,0 +1,45 @@
+using Ocelot.Responses;
+using System.Threading.Tasks;
+
+namespace Ocelot.Configuration.Repository
+{
+ public class ConsulFileConfigurationPollerOption : IFileConfigurationPollerOptions
+ {
+ private readonly IInternalConfigurationRepository _internalConfigRepo;
+ private readonly IFileConfigurationRepository _fileConfigurationRepository;
+
+ public ConsulFileConfigurationPollerOption(IInternalConfigurationRepository internalConfigurationRepository,
+ IFileConfigurationRepository fileConfigurationRepository)
+ {
+ _internalConfigRepo = internalConfigurationRepository;
+ _fileConfigurationRepository = fileConfigurationRepository;
+ }
+
+ public int Delay => GetDelay();
+
+ private int GetDelay()
+ {
+ int delay = 1000;
+
+ Response fileConfig = Task.Run(async () => await _fileConfigurationRepository.Get()).Result;
+ if (fileConfig?.Data?.GlobalConfiguration?.ServiceDiscoveryProvider != null &&
+ !fileConfig.IsError &&
+ fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval > 0)
+ {
+ delay = fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval;
+ }
+ else
+ {
+ Response internalConfig = _internalConfigRepo.Get();
+ if (internalConfig?.Data?.ServiceProviderConfiguration != null &&
+ !internalConfig.IsError &&
+ internalConfig.Data.ServiceProviderConfiguration.PollingInterval > 0)
+ {
+ delay = internalConfig.Data.ServiceProviderConfiguration.PollingInterval;
+ }
+ }
+
+ return delay;
+ }
+ }
+}
diff --git a/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs
index 0141abd7..8df82935 100644
--- a/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs
+++ b/src/Ocelot/Configuration/Repository/DiskFileConfigurationRepository.cs
@@ -1,9 +1,9 @@
-using System;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Newtonsoft.Json;
using Ocelot.Configuration.File;
using Ocelot.Responses;
+using System;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Repository
{
@@ -25,7 +25,7 @@ namespace Ocelot.Configuration.Repository
{
string jsonConfiguration;
- lock(_lock)
+ lock (_lock)
{
jsonConfiguration = System.IO.File.ReadAllText(_environmentFilePath);
}
@@ -39,7 +39,7 @@ namespace Ocelot.Configuration.Repository
{
string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration, Formatting.Indented);
- lock(_lock)
+ lock (_lock)
{
if (System.IO.File.Exists(_environmentFilePath))
{
diff --git a/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs b/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs
index 84fc7918..cca50d0b 100644
--- a/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs
+++ b/src/Ocelot/Configuration/Repository/FileConfigurationPoller.cs
@@ -1,19 +1,18 @@
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
-using Ocelot.Configuration.Setter;
using Ocelot.Logging;
+using System;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Repository
{
public class FileConfigurationPoller : IHostedService, IDisposable
{
- private readonly IOcelotLogger _logger;
+ private readonly IOcelotLogger _logger;
private readonly IFileConfigurationRepository _repo;
private string _previousAsJson;
private Timer _timer;
@@ -23,8 +22,8 @@ namespace Ocelot.Configuration.Repository
private readonly IInternalConfigurationCreator _internalConfigCreator;
public FileConfigurationPoller(
- IOcelotLoggerFactory factory,
- IFileConfigurationRepository repo,
+ IOcelotLoggerFactory factory,
+ IFileConfigurationRepository repo,
IFileConfigurationPollerOptions options,
IInternalConfigurationRepository internalConfigRepo,
IInternalConfigurationCreator internalConfigCreator)
@@ -36,18 +35,18 @@ namespace Ocelot.Configuration.Repository
_repo = repo;
_previousAsJson = "";
}
-
+
public Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation($"{nameof(FileConfigurationPoller)} is starting.");
_timer = new Timer(async x =>
{
- if(_polling)
+ if (_polling)
{
return;
}
-
+
_polling = true;
await Poll();
_polling = false;
@@ -62,7 +61,7 @@ namespace Ocelot.Configuration.Repository
_timer?.Change(Timeout.Infinite, 0);
- return Task.CompletedTask;
+ return Task.CompletedTask;
}
private async Task Poll()
@@ -71,7 +70,7 @@ namespace Ocelot.Configuration.Repository
var fileConfig = await _repo.Get();
- if(fileConfig.IsError)
+ if (fileConfig.IsError)
{
_logger.LogWarning($"error geting file config, errors are {string.Join(",", fileConfig.Errors.Select(x => x.Message))}");
return;
@@ -79,11 +78,11 @@ namespace Ocelot.Configuration.Repository
var asJson = ToJson(fileConfig.Data);
- if(!fileConfig.IsError && asJson != _previousAsJson)
+ if (!fileConfig.IsError && asJson != _previousAsJson)
{
var config = await _internalConfigCreator.Create(fileConfig.Data);
- if(!config.IsError)
+ if (!config.IsError)
{
_internalConfigRepo.AddOrReplace(config.Data);
}
diff --git a/src/Ocelot/Configuration/Repository/IFileConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/IFileConfigurationRepository.cs
index 2fe8140a..55ad6ce7 100644
--- a/src/Ocelot/Configuration/Repository/IFileConfigurationRepository.cs
+++ b/src/Ocelot/Configuration/Repository/IFileConfigurationRepository.cs
@@ -1,12 +1,13 @@
-using System.Threading.Tasks;
using Ocelot.Configuration.File;
using Ocelot.Responses;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Repository
{
public interface IFileConfigurationRepository
{
Task> Get();
+
Task Set(FileConfiguration fileConfiguration);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Repository/IInternalConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/IInternalConfigurationRepository.cs
index 5db4adb5..136bf321 100644
--- a/src/Ocelot/Configuration/Repository/IInternalConfigurationRepository.cs
+++ b/src/Ocelot/Configuration/Repository/IInternalConfigurationRepository.cs
@@ -5,6 +5,7 @@ namespace Ocelot.Configuration.Repository
public interface IInternalConfigurationRepository
{
Response Get();
+
Response AddOrReplace(IInternalConfiguration internalConfiguration);
}
}
diff --git a/src/Ocelot/Configuration/SecurityOptions.cs b/src/Ocelot/Configuration/SecurityOptions.cs
index 88d4d08a..e4cf4205 100644
--- a/src/Ocelot/Configuration/SecurityOptions.cs
+++ b/src/Ocelot/Configuration/SecurityOptions.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
namespace Ocelot.Configuration
{
diff --git a/src/Ocelot/Configuration/Setter/FileAndInternalConfigurationSetter.cs b/src/Ocelot/Configuration/Setter/FileAndInternalConfigurationSetter.cs
index a5549b29..127e20be 100644
--- a/src/Ocelot/Configuration/Setter/FileAndInternalConfigurationSetter.cs
+++ b/src/Ocelot/Configuration/Setter/FileAndInternalConfigurationSetter.cs
@@ -1,8 +1,8 @@
-using System.Threading.Tasks;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Repository;
using Ocelot.Responses;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Setter
{
@@ -13,8 +13,8 @@ namespace Ocelot.Configuration.Setter
private readonly IFileConfigurationRepository _repo;
public FileAndInternalConfigurationSetter(
- IInternalConfigurationRepository configRepo,
- IInternalConfigurationCreator configCreator,
+ IInternalConfigurationRepository configRepo,
+ IInternalConfigurationCreator configCreator,
IFileConfigurationRepository repo)
{
internalConfigRepo = configRepo;
@@ -26,14 +26,14 @@ namespace Ocelot.Configuration.Setter
{
var response = await _repo.Set(fileConfig);
- if(response.IsError)
+ if (response.IsError)
{
return new ErrorResponse(response.Errors);
}
var config = await _configCreator.Create(fileConfig);
- if(!config.IsError)
+ if (!config.IsError)
{
internalConfigRepo.AddOrReplace(config.Data);
}
diff --git a/src/Ocelot/Configuration/Setter/IFileConfigurationSetter.cs b/src/Ocelot/Configuration/Setter/IFileConfigurationSetter.cs
index 28fec505..9e8b4cc7 100644
--- a/src/Ocelot/Configuration/Setter/IFileConfigurationSetter.cs
+++ b/src/Ocelot/Configuration/Setter/IFileConfigurationSetter.cs
@@ -1,6 +1,6 @@
-using System.Threading.Tasks;
using Ocelot.Configuration.File;
using Ocelot.Responses;
+using System.Threading.Tasks;
namespace Ocelot.Configuration.Setter
{
diff --git a/src/Ocelot/Configuration/Validator/ConfigurationValidationResult.cs b/src/Ocelot/Configuration/Validator/ConfigurationValidationResult.cs
index d8add08a..d1c87530 100644
--- a/src/Ocelot/Configuration/Validator/ConfigurationValidationResult.cs
+++ b/src/Ocelot/Configuration/Validator/ConfigurationValidationResult.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Configuration.Validator
{
- using System.Collections.Generic;
using Ocelot.Errors;
+ using System.Collections.Generic;
public class ConfigurationValidationResult
{
@@ -19,6 +19,6 @@
public bool IsError { get; }
- public List Errors { get; }
+ public List Errors { get; }
}
}
diff --git a/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs b/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs
index 728c218f..49e92355 100644
--- a/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs
+++ b/src/Ocelot/Configuration/Validator/FileConfigurationFluentValidator.cs
@@ -1,15 +1,15 @@
namespace Ocelot.Configuration.Validator
{
- using FluentValidation;
- using File;
using Errors;
+ using File;
+ using FluentValidation;
+ using Microsoft.Extensions.DependencyInjection;
using Responses;
+ using ServiceDiscovery;
+ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
- using System;
- using Microsoft.Extensions.DependencyInjection;
- using ServiceDiscovery;
public class FileConfigurationFluentValidator : AbstractValidator, IConfigurationValidator
{
@@ -73,11 +73,11 @@
private bool HaveServiceDiscoveryProviderRegistered(FileServiceDiscoveryProvider serviceDiscoveryProvider)
{
- if(serviceDiscoveryProvider == null)
+ if (serviceDiscoveryProvider == null)
{
return true;
}
-
+
if (serviceDiscoveryProvider?.Type?.ToLower() == "servicefabric")
{
return true;
diff --git a/src/Ocelot/Configuration/Validator/FileGlobalConfigurationFluentValidator.cs b/src/Ocelot/Configuration/Validator/FileGlobalConfigurationFluentValidator.cs
index fbad7645..22e1690f 100644
--- a/src/Ocelot/Configuration/Validator/FileGlobalConfigurationFluentValidator.cs
+++ b/src/Ocelot/Configuration/Validator/FileGlobalConfigurationFluentValidator.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Configuration.Validator
{
- using FluentValidation;
using File;
+ using FluentValidation;
public class FileGlobalConfigurationFluentValidator : AbstractValidator
{
diff --git a/src/Ocelot/Configuration/Validator/FileQoSOptionsFluentValidator.cs b/src/Ocelot/Configuration/Validator/FileQoSOptionsFluentValidator.cs
index 3c0d532b..4a6c8496 100644
--- a/src/Ocelot/Configuration/Validator/FileQoSOptionsFluentValidator.cs
+++ b/src/Ocelot/Configuration/Validator/FileQoSOptionsFluentValidator.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Configuration.Validator
{
- using System;
- using FluentValidation;
using File;
+ using FluentValidation;
using Microsoft.Extensions.DependencyInjection;
using Requester;
+ using System;
public class FileQoSOptionsFluentValidator : AbstractValidator
{
@@ -14,10 +14,11 @@ namespace Ocelot.Configuration.Validator
{
_qosDelegatingHandlerDelegate = provider.GetService();
- When(qosOptions => qosOptions.TimeoutValue > 0 && qosOptions.ExceptionsAllowedBeforeBreaking > 0, () => {
+ When(qosOptions => qosOptions.TimeoutValue > 0 && qosOptions.ExceptionsAllowedBeforeBreaking > 0, () =>
+ {
RuleFor(qosOptions => qosOptions)
.Must(HaveQosHandlerRegistered)
- .WithMessage("Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using QoSOptions but no QosDelegatingHandlerDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Polly and services.AddPolly()?");
+ .WithMessage("Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using QoSOptions but no QosDelegatingHandlerDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Polly and services.AddPolly()?");
});
}
diff --git a/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs b/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs
index 937b896b..a1918341 100644
--- a/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs
+++ b/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs
@@ -4,9 +4,9 @@
public class FileValidationFailedError : Error
{
- public FileValidationFailedError(string message)
+ public FileValidationFailedError(string message)
: base(message, OcelotErrorCode.FileValidationFailedError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs b/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
index 39f90c81..f9b7eef9 100644
--- a/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
+++ b/src/Ocelot/Configuration/Validator/IConfigurationValidator.cs
@@ -1,11 +1,11 @@
namespace Ocelot.Configuration.Validator
{
- using System.Threading.Tasks;
using Ocelot.Configuration.File;
using Ocelot.Responses;
+ using System.Threading.Tasks;
public interface IConfigurationValidator
{
Task> IsValid(FileConfiguration configuration);
}
-}
+}
diff --git a/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs b/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs
index e91c2f00..724d92bb 100644
--- a/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs
+++ b/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs
@@ -1,9 +1,8 @@
namespace Ocelot.Configuration.Validator
{
- using System;
+ using File;
using FluentValidation;
using Microsoft.AspNetCore.Authentication;
- using File;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
@@ -73,12 +72,14 @@
.MustAsync(IsSupportedAuthenticationProviders)
.WithMessage("{PropertyName} {PropertyValue} is unsupported authentication provider");
- When(reRoute => string.IsNullOrEmpty(reRoute.ServiceName), () => {
+ When(reRoute => string.IsNullOrEmpty(reRoute.ServiceName), () =>
+ {
RuleFor(r => r.DownstreamHostAndPorts).NotEmpty()
.WithMessage("When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!");
});
- When(reRoute => string.IsNullOrEmpty(reRoute.ServiceName), () => {
+ When(reRoute => string.IsNullOrEmpty(reRoute.ServiceName), () =>
+ {
RuleFor(reRoute => reRoute.DownstreamHostAndPorts)
.SetCollectionValidator(hostAndPortValidator);
});
diff --git a/src/Ocelot/DependencyInjection/AdministrationPath.cs b/src/Ocelot/DependencyInjection/AdministrationPath.cs
index b76fdbb2..13f4c0d1 100644
--- a/src/Ocelot/DependencyInjection/AdministrationPath.cs
+++ b/src/Ocelot/DependencyInjection/AdministrationPath.cs
@@ -7,6 +7,6 @@ namespace Ocelot.DependencyInjection
Path = path;
}
- public string Path {get;private set;}
+ public string Path { get; private set; }
}
}
diff --git a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs
index 02b5a17b..8d75bd97 100644
--- a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs
+++ b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs
@@ -1,15 +1,15 @@
namespace Ocelot.DependencyInjection
{
- using System;
- using System.Collections.Generic;
+ using Configuration.File;
+ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Memory;
+ using Newtonsoft.Json;
+ using System;
+ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
- using Configuration.File;
- using Newtonsoft.Json;
- using Microsoft.AspNetCore.Hosting;
public static class ConfigurationBuilderExtensions
{
@@ -55,13 +55,13 @@ namespace Ocelot.DependencyInjection
foreach (var file in files)
{
- if(files.Count > 1 && file.Name.Equals(primaryConfigFile, StringComparison.OrdinalIgnoreCase))
+ if (files.Count > 1 && file.Name.Equals(primaryConfigFile, StringComparison.OrdinalIgnoreCase))
{
continue;
}
var lines = File.ReadAllText(file.FullName);
-
+
var config = JsonConvert.DeserializeObject(lines);
if (file.Name.Equals(globalConfigFile, StringComparison.OrdinalIgnoreCase))
diff --git a/src/Ocelot/DependencyInjection/IAdministrationPath.cs b/src/Ocelot/DependencyInjection/IAdministrationPath.cs
index a206652f..856e0fa3 100644
--- a/src/Ocelot/DependencyInjection/IAdministrationPath.cs
+++ b/src/Ocelot/DependencyInjection/IAdministrationPath.cs
@@ -2,6 +2,6 @@ namespace Ocelot.DependencyInjection
{
public interface IAdministrationPath
{
- string Path {get;}
+ string Path { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/DependencyInjection/IOcelotBuilder.cs b/src/Ocelot/DependencyInjection/IOcelotBuilder.cs
index 34841c80..5e4421be 100644
--- a/src/Ocelot/DependencyInjection/IOcelotBuilder.cs
+++ b/src/Ocelot/DependencyInjection/IOcelotBuilder.cs
@@ -1,8 +1,7 @@
-using System;
-using System.Net.Http;
-using Ocelot.Middleware.Multiplexer;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Ocelot.Middleware.Multiplexer;
+using System.Net.Http;
namespace Ocelot.DependencyInjection
{
@@ -17,10 +16,10 @@ namespace Ocelot.DependencyInjection
IOcelotBuilder AddDelegatingHandler(bool global = false)
where T : DelegatingHandler;
- IOcelotBuilder AddSingletonDefinedAggregator()
+ IOcelotBuilder AddSingletonDefinedAggregator()
where T : class, IDefinedAggregator;
- IOcelotBuilder AddTransientDefinedAggregator()
+ IOcelotBuilder AddTransientDefinedAggregator()
where T : class, IDefinedAggregator;
}
}
diff --git a/src/Ocelot/DependencyInjection/OcelotAdministrationBuilder.cs b/src/Ocelot/DependencyInjection/OcelotAdministrationBuilder.cs
index 6e59284f..1ef75d06 100644
--- a/src/Ocelot/DependencyInjection/OcelotAdministrationBuilder.cs
+++ b/src/Ocelot/DependencyInjection/OcelotAdministrationBuilder.cs
@@ -11,7 +11,7 @@ namespace Ocelot.DependencyInjection
public OcelotAdministrationBuilder(IServiceCollection services, IConfiguration configurationRoot)
{
ConfigurationRoot = configurationRoot;
- Services = services;
+ Services = services;
}
}
}
diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs
index 3fee15e7..958f6841 100644
--- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs
+++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs
@@ -3,9 +3,11 @@ namespace Ocelot.DependencyInjection
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.DependencyInjection.Extensions;
using Ocelot.Authorisation;
using Ocelot.Cache;
using Ocelot.Claims;
+ using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Parser;
@@ -16,27 +18,25 @@ namespace Ocelot.DependencyInjection
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
using Ocelot.Headers;
+ using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Infrastructure.RequestData;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Logging;
using Ocelot.Middleware;
+ using Ocelot.Middleware.Multiplexer;
using Ocelot.QueryStrings;
using Ocelot.RateLimit;
+ using Ocelot.Request.Creator;
using Ocelot.Request.Mapper;
using Ocelot.Requester;
using Ocelot.Requester.QoS;
using Ocelot.Responder;
- using Ocelot.ServiceDiscovery;
- using System.Reflection;
- using Ocelot.Configuration;
- using Microsoft.Extensions.DependencyInjection.Extensions;
- using System.Net.Http;
- using Ocelot.Infrastructure;
- using Ocelot.Middleware.Multiplexer;
- using Ocelot.Request.Creator;
- using Ocelot.Security.IPSecurity;
using Ocelot.Security;
+ using Ocelot.Security.IPSecurity;
+ using Ocelot.ServiceDiscovery;
+ using System.Net.Http;
+ using System.Reflection;
public class OcelotBuilder : IOcelotBuilder
{
diff --git a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
index e3f90665..030e9957 100644
--- a/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
+++ b/src/Ocelot/DependencyInjection/ServiceCollectionExtensions.cs
@@ -1,5 +1,4 @@
-using System;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
@@ -19,4 +18,4 @@ namespace Ocelot.DependencyInjection
return new OcelotBuilder(services, configuration);
}
}
-}
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs b/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs
index c7696ecf..a691e11e 100644
--- a/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs
+++ b/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
+using System.Collections.Generic;
namespace Ocelot.DownstreamRouteFinder
{
@@ -15,4 +15,4 @@ namespace Ocelot.DownstreamRouteFinder
public List TemplatePlaceholderNameAndValues { get; private set; }
public ReRoute ReRoute { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteCreator.cs b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteCreator.cs
index b032555d..ec6821ad 100644
--- a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteCreator.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteCreator.cs
@@ -1,14 +1,13 @@
namespace Ocelot.DownstreamRouteFinder.Finder
{
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
using Configuration;
using Configuration.Builder;
using Configuration.Creator;
- using Configuration.File;
using LoadBalancer.LoadBalancers;
using Responses;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Linq;
using UrlMatcher;
public class DownstreamRouteCreator : IDownstreamRouteProvider
@@ -23,12 +22,12 @@
}
public Response Get(string upstreamUrlPath, string upstreamQueryString, string upstreamHttpMethod, IInternalConfiguration configuration, string upstreamHost)
- {
+ {
var serviceName = GetServiceName(upstreamUrlPath);
var downstreamPath = GetDownstreamPath(upstreamUrlPath);
- if(HasQueryString(downstreamPath))
+ if (HasQueryString(downstreamPath))
{
downstreamPath = RemoveQueryString(downstreamPath);
}
@@ -37,7 +36,7 @@
var loadBalancerKey = CreateLoadBalancerKey(downstreamPathForKeys, upstreamHttpMethod, configuration.LoadBalancerOptions);
- if(_cache.TryGetValue(loadBalancerKey, out var downstreamRoute))
+ if (_cache.TryGetValue(loadBalancerKey, out var downstreamRoute))
{
return downstreamRoute;
}
@@ -57,31 +56,31 @@
.WithLoadBalancerOptions(configuration.LoadBalancerOptions)
.WithUpstreamPathTemplate(upstreamPathTemplate);
- var rateLimitOptions = configuration.ReRoutes != null
- ? configuration.ReRoutes
- .SelectMany(x => x.DownstreamReRoute)
- .FirstOrDefault(x => x.ServiceName == serviceName)
- : null;
+ var rateLimitOptions = configuration.ReRoutes != null
+ ? configuration.ReRoutes
+ .SelectMany(x => x.DownstreamReRoute)
+ .FirstOrDefault(x => x.ServiceName == serviceName)
+ : null;
- if(rateLimitOptions != null)
- {
- downstreamReRouteBuilder
- .WithRateLimitOptions(rateLimitOptions.RateLimitOptions)
- .WithEnableRateLimiting(true);
- }
-
- var downstreamReRoute = downstreamReRouteBuilder.Build();
+ if (rateLimitOptions != null)
+ {
+ downstreamReRouteBuilder
+ .WithRateLimitOptions(rateLimitOptions.RateLimitOptions)
+ .WithEnableRateLimiting(true);
+ }
+
+ var downstreamReRoute = downstreamReRouteBuilder.Build();
var reRoute = new ReRouteBuilder()
.WithDownstreamReRoute(downstreamReRoute)
- .WithUpstreamHttpMethod(new List(){ upstreamHttpMethod })
+ .WithUpstreamHttpMethod(new List() { upstreamHttpMethod })
.WithUpstreamPathTemplate(upstreamPathTemplate)
.Build();
downstreamRoute = new OkResponse(new DownstreamRoute(new List(), reRoute));
_cache.AddOrUpdate(loadBalancerKey, downstreamRoute, (x, y) => downstreamRoute);
-
+
return downstreamRoute;
}
@@ -98,7 +97,7 @@
private static string GetDownstreamPath(string upstreamUrlPath)
{
- if(upstreamUrlPath.IndexOf('/', 1) == -1)
+ if (upstreamUrlPath.IndexOf('/', 1) == -1)
{
return "/";
}
@@ -109,7 +108,7 @@
private static string GetServiceName(string upstreamUrlPath)
{
- if(upstreamUrlPath.IndexOf('/', 1) == -1)
+ if (upstreamUrlPath.IndexOf('/', 1) == -1)
{
return upstreamUrlPath
.Substring(1);
diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
index a66d2a04..115fbd42 100644
--- a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs
@@ -1,9 +1,8 @@
-using System.Collections.Generic;
-using System.Linq;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
-using Ocelot.Errors;
using Ocelot.Responses;
+using System.Collections.Generic;
+using System.Linq;
namespace Ocelot.DownstreamRouteFinder.Finder
{
diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteProviderFactory.cs b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteProviderFactory.cs
index 319e9191..32f68936 100644
--- a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteProviderFactory.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteProviderFactory.cs
@@ -1,17 +1,17 @@
namespace Ocelot.DownstreamRouteFinder.Finder
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
using Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Logging;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
public class DownstreamRouteProviderFactory : IDownstreamRouteProviderFactory
{
private readonly Dictionary _providers;
private readonly IOcelotLogger _logger;
-
+
public DownstreamRouteProviderFactory(IServiceProvider provider, IOcelotLoggerFactory factory)
{
_logger = factory.CreateLogger();
@@ -22,18 +22,18 @@
{
//todo - this is a bit hacky we are saying there are no reRoutes or there are reRoutes but none of them have
//an upstream path template which means they are dyanmic and service discovery is on...
- if((!config.ReRoutes.Any() || config.ReRoutes.All(x => string.IsNullOrEmpty(x.UpstreamTemplatePattern?.OriginalValue))) && IsServiceDiscovery(config.ServiceProviderConfiguration))
+ if ((!config.ReRoutes.Any() || config.ReRoutes.All(x => string.IsNullOrEmpty(x.UpstreamTemplatePattern?.OriginalValue))) && IsServiceDiscovery(config.ServiceProviderConfiguration))
{
_logger.LogInformation($"Selected {nameof(DownstreamRouteCreator)} as DownstreamRouteProvider for this request");
return _providers[nameof(DownstreamRouteCreator)];
}
-
+
return _providers[nameof(DownstreamRouteFinder)];
}
private bool IsServiceDiscovery(ServiceProviderConfiguration config)
{
- if(!string.IsNullOrEmpty(config?.Host) && config?.Port > 0 && !string.IsNullOrEmpty(config.Type))
+ if (!string.IsNullOrEmpty(config?.Host) && config?.Port > 0 && !string.IsNullOrEmpty(config.Type))
{
return true;
}
diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/IDownstreamRouteProvider.cs b/src/Ocelot/DownstreamRouteFinder/Finder/IDownstreamRouteProvider.cs
index 0a84f8f4..b2809ac9 100644
--- a/src/Ocelot/DownstreamRouteFinder/Finder/IDownstreamRouteProvider.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Finder/IDownstreamRouteProvider.cs
@@ -1,5 +1,4 @@
-using System.Threading.Tasks;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.Responses;
namespace Ocelot.DownstreamRouteFinder.Finder
diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/UnableToFindDownstreamRouteError.cs b/src/Ocelot/DownstreamRouteFinder/Finder/UnableToFindDownstreamRouteError.cs
index cd7141a8..5a0a358c 100644
--- a/src/Ocelot/DownstreamRouteFinder/Finder/UnableToFindDownstreamRouteError.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Finder/UnableToFindDownstreamRouteError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.DownstreamRouteFinder.Finder
{
public class UnableToFindDownstreamRouteError : Error
{
- public UnableToFindDownstreamRouteError(string path, string httpVerb)
+ public UnableToFindDownstreamRouteError(string path, string httpVerb)
: base($"Failed to match ReRoute configuration for upstream path: {path}, verb: {httpVerb}.", OcelotErrorCode.UnableToFindDownstreamRouteError)
{
}
}
-}
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs
index c9b534ed..8ac0705c 100644
--- a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs
@@ -1,11 +1,10 @@
-using System.Threading.Tasks;
-using System.Linq;
-using Ocelot.Configuration.Repository;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
+using System.Linq;
+using System.Threading.Tasks;
namespace Ocelot.DownstreamRouteFinder.Middleware
{
@@ -19,7 +18,7 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
IOcelotLoggerFactory loggerFactory,
IDownstreamRouteProviderFactory downstreamRouteFinder,
IMultiplexer multiplexer)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_multiplexer = multiplexer;
_next = next;
@@ -46,10 +45,10 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
SetPipelineError(context, downstreamRoute.Errors);
return;
- }
-
+ }
+
var downstreamPathTemplates = string.Join(", ", downstreamRoute.Data.ReRoute.DownstreamReRoute.Select(r => r.DownstreamPathTemplate.Value));
-
+
Logger.LogDebug($"downstream templates are {downstreamPathTemplates}");
context.TemplatePlaceholderNameAndValues = downstreamRoute.Data.TemplatePlaceholderNameAndValues;
diff --git a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddlewareExtensions.cs b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddlewareExtensions.cs
index 13dacac8..08a856b6 100644
--- a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddlewareExtensions.cs
+++ b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs
index 986d7b84..c9b16260 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
-using Ocelot.Responses;
+using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.DownstreamRouteFinder.UrlMatcher
{
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathToUrlTemplateMatcher.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathToUrlTemplateMatcher.cs
index 9d6ffb4e..d9d3a45f 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathToUrlTemplateMatcher.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathToUrlTemplateMatcher.cs
@@ -4,7 +4,7 @@ using Ocelot.Values;
namespace Ocelot.DownstreamRouteFinder.UrlMatcher
{
public interface IUrlPathToUrlTemplateMatcher
- {
+ {
Response Match(string upstreamUrlPath, string upstreamQueryString, UpstreamPathTemplate pathTemplate);
- }
-}
+ }
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs
index 90099d58..4bd29414 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs
@@ -8,7 +8,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
Value = value;
}
- public string Name {get;private set;}
- public string Value {get;private set;}
+ public string Name { get; private set; }
+ public string Value { get; private set; }
}
}
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/RegExUrlMatcher.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/RegExUrlMatcher.cs
index 84b91304..a4979f4d 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/RegExUrlMatcher.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/RegExUrlMatcher.cs
@@ -1,5 +1,4 @@
-using System.Text.RegularExpressions;
-using Ocelot.Responses;
+using Ocelot.Responses;
using Ocelot.Values;
namespace Ocelot.DownstreamRouteFinder.UrlMatcher
@@ -15,8 +14,8 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
: new OkResponse(new UrlMatch(false));
}
- return pathTemplate.Pattern.IsMatch($"{upstreamUrlPath}{upstreamQueryString}")
- ? new OkResponse(new UrlMatch(true))
+ return pathTemplate.Pattern.IsMatch($"{upstreamUrlPath}{upstreamQueryString}")
+ ? new OkResponse(new UrlMatch(true))
: new OkResponse(new UrlMatch(false));
}
}
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs
index 9236ae39..9ef6396c 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs
@@ -4,9 +4,9 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
{
public UrlMatch(bool match)
{
- Match = match;
+ Match = match;
}
- public bool Match {get;private set;}
+ public bool Match { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs
index bb59fac4..50f1ef7a 100644
--- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs
+++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.DownstreamRouteFinder.UrlMatcher
{
@@ -18,7 +18,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
for (int counterForTemplate = 0; counterForTemplate < pathTemplate.Length; counterForTemplate++)
{
- if ((path.Length > counterForPath) && CharactersDontMatch(pathTemplate[counterForTemplate], path[counterForPath]) && ContinueScanningUrl(counterForPath,path.Length))
+ if ((path.Length > counterForPath) && CharactersDontMatch(pathTemplate[counterForTemplate], path[counterForPath]) && ContinueScanningUrl(counterForPath, path.Length))
{
if (IsPlaceholder(pathTemplate[counterForTemplate]))
{
@@ -51,13 +51,13 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
return new OkResponse>(placeHolderNameAndValues);
}
- else if(IsCatchAll(path, counterForPath, pathTemplate))
+ else if (IsCatchAll(path, counterForPath, pathTemplate))
{
var endOfPlaceholder = GetNextCounterPosition(pathTemplate, counterForTemplate, '}');
var placeholderName = GetPlaceholderName(pathTemplate, 1);
- if(NothingAfterFirstForwardSlash(path))
+ if (NothingAfterFirstForwardSlash(path))
{
placeHolderNameAndValues.Add(new PlaceholderNameAndValue(placeholderName, ""));
}
@@ -93,8 +93,8 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
private bool IsCatchAll(string path, int counterForPath, string pathTemplate)
{
- return string.IsNullOrEmpty(path) || (path.Length > counterForPath && path[counterForPath] == '/') && pathTemplate.Length > 1
- && pathTemplate.Substring(0, 2) == "/{"
+ return string.IsNullOrEmpty(path) || (path.Length > counterForPath && path[counterForPath] == '/') && pathTemplate.Length > 1
+ && pathTemplate.Substring(0, 2) == "/{"
&& pathTemplate.IndexOf('}') == pathTemplate.Length - 1;
}
@@ -127,9 +127,9 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
}
private int GetNextCounterPosition(string urlTemplate, int counterForTemplate, char delimiter)
- {
+ {
var closingPlaceHolderPositionOnTemplate = urlTemplate.IndexOf(delimiter, counterForTemplate);
- return closingPlaceHolderPositionOnTemplate + 1;
+ return closingPlaceHolderPositionOnTemplate + 1;
}
private bool CharactersDontMatch(char characterOne, char characterTwo)
diff --git a/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddleware.cs b/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddleware.cs
index 1e545d28..d2e53b95 100644
--- a/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddleware.cs
+++ b/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddleware.cs
@@ -1,10 +1,10 @@
-using System.Threading.Tasks;
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
using Ocelot.Logging;
using Ocelot.Middleware;
-using System;
using Ocelot.Responses;
using Ocelot.Values;
+using System;
+using System.Threading.Tasks;
namespace Ocelot.DownstreamUrlCreator.Middleware
{
@@ -18,7 +18,7 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
public DownstreamUrlCreatorMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
IDownstreamPathPlaceholderReplacer replacer)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_replacer = replacer;
@@ -49,7 +49,7 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
{
var dsPath = response.Data;
- if(ContainsQueryString(dsPath))
+ if (ContainsQueryString(dsPath))
{
context.DownstreamRequest.AbsolutePath = GetPath(dsPath);
@@ -115,7 +115,7 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
private (string path, string query) CreateServiceFabricUri(DownstreamContext context, Response dsPath)
{
- var query = context.DownstreamRequest.Query;
+ var query = context.DownstreamRequest.Query;
var serviceName = _replacer.Replace(context.DownstreamReRoute.ServiceName, context.TemplatePlaceholderNameAndValues);
var pathTemplate = $"/{serviceName.Data.Value}{dsPath.Data.Value}";
return (pathTemplate, query);
diff --git a/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddlewareExtensions.cs b/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddlewareExtensions.cs
index 671636c5..8904d3af 100644
--- a/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddlewareExtensions.cs
+++ b/src/Ocelot/DownstreamUrlCreator/Middleware/DownstreamUrlCreatorMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs
index ac91ef2e..a58c6607 100644
--- a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs
+++ b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs
@@ -1,8 +1,8 @@
-using System.Collections.Generic;
-using System.Text;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Ocelot.Values;
+using System.Collections.Generic;
+using System.Text;
namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer
{
diff --git a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs
index 237f20fc..e6c0864a 100644
--- a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs
+++ b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs
@@ -1,12 +1,12 @@
-using System.Collections.Generic;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Ocelot.Values;
+using System.Collections.Generic;
namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer
{
public interface IDownstreamPathPlaceholderReplacer
{
- Response Replace(string downstreamPathTemplate, List urlPathPlaceholderNameAndValues);
+ Response Replace(string downstreamPathTemplate, List urlPathPlaceholderNameAndValues);
}
}
diff --git a/src/Ocelot/Errors/Error.cs b/src/Ocelot/Errors/Error.cs
index e063934b..18c3c49f 100644
--- a/src/Ocelot/Errors/Error.cs
+++ b/src/Ocelot/Errors/Error.cs
@@ -1,6 +1,6 @@
namespace Ocelot.Errors
{
- public abstract class Error
+ public abstract class Error
{
protected Error(string message, OcelotErrorCode code)
{
@@ -16,4 +16,4 @@ namespace Ocelot.Errors
return Message;
}
}
-}
+}
diff --git a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs
index 58c18901..6d583e66 100644
--- a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs
+++ b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs
@@ -1,15 +1,15 @@
namespace Ocelot.Errors.Middleware
{
using Configuration;
- using System;
- using System.Linq;
- using System.Threading.Tasks;
using Ocelot.Configuration.Repository;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware;
-
+ using System;
+ using System.Linq;
+ using System.Threading.Tasks;
+
///
/// Catches all unhandled exceptions thrown by middleware, logs and returns a 500
///
@@ -21,7 +21,7 @@ namespace Ocelot.Errors.Middleware
public ExceptionHandlerMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
- IInternalConfigurationRepository configRepo,
+ IInternalConfigurationRepository configRepo,
IRequestScopedDataRepository repo)
: base(loggerFactory.CreateLogger())
{
@@ -34,6 +34,8 @@ namespace Ocelot.Errors.Middleware
{
try
{
+ context.HttpContext.RequestAborted.ThrowIfCancellationRequested();
+
//try and get the global request id and set it for logs...
//should this basically be immutable per request...i guess it should!
//first thing is get config
@@ -52,6 +54,14 @@ namespace Ocelot.Errors.Middleware
await _next.Invoke(context);
}
+ catch (OperationCanceledException e) when (context.HttpContext.RequestAborted.IsCancellationRequested)
+ {
+ Logger.LogDebug("operation canceled");
+ if (!context.HttpContext.Response.HasStarted)
+ {
+ context.HttpContext.Response.StatusCode = 499;
+ }
+ }
catch (Exception e)
{
Logger.LogDebug("error calling middleware");
@@ -59,7 +69,7 @@ namespace Ocelot.Errors.Middleware
var message = CreateMessage(context, e);
Logger.LogError(message, e);
-
+
SetInternalServerErrorOnResponse(context);
}
diff --git a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddlewareExtensions.cs b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddlewareExtensions.cs
index 5d8874b0..82e1050e 100644
--- a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddlewareExtensions.cs
+++ b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Errors.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Errors/OcelotErrorCode.cs b/src/Ocelot/Errors/OcelotErrorCode.cs
index dd2c249a..d8b6f333 100644
--- a/src/Ocelot/Errors/OcelotErrorCode.cs
+++ b/src/Ocelot/Errors/OcelotErrorCode.cs
@@ -2,42 +2,43 @@
{
public enum OcelotErrorCode
{
- UnauthenticatedError,
- UnknownError,
- DownstreampathTemplateAlreadyUsedError,
- UnableToFindDownstreamRouteError,
- CannotAddDataError,
- CannotFindDataError,
- UnableToCompleteRequestError,
- UnableToCreateAuthenticationHandlerError,
- UnsupportedAuthenticationProviderError,
- CannotFindClaimError,
- ParsingConfigurationHeaderError,
- NoInstructionsError,
- InstructionNotForClaimsError,
- UnauthorizedError,
- ClaimValueNotAuthorisedError,
- ScopeNotAuthorisedError,
- UserDoesNotHaveClaimError,
- DownstreamPathTemplateContainsSchemeError,
- DownstreamPathNullOrEmptyError,
- DownstreamSchemeNullOrEmptyError,
- DownstreamHostNullOrEmptyError,
- ServicesAreNullError,
- ServicesAreEmptyError,
- UnableToFindServiceDiscoveryProviderError,
- UnableToFindLoadBalancerError,
- RequestTimedOutError,
- UnableToFindQoSProviderError,
- UnmappableRequestError,
- RateLimitOptionsError,
- PathTemplateDoesntStartWithForwardSlash,
- FileValidationFailedError,
- UnableToFindDelegatingHandlerProviderError,
- CouldNotFindPlaceholderError,
- CouldNotFindAggregatorError,
- CannotAddPlaceholderError,
- CannotRemovePlaceholderError,
- QuotaExceededError
+ UnauthenticatedError = 0,
+ UnknownError = 1,
+ DownstreampathTemplateAlreadyUsedError = 2,
+ UnableToFindDownstreamRouteError = 3,
+ CannotAddDataError = 4,
+ CannotFindDataError = 5,
+ UnableToCompleteRequestError = 6,
+ UnableToCreateAuthenticationHandlerError = 7,
+ UnsupportedAuthenticationProviderError = 8,
+ CannotFindClaimError = 9,
+ ParsingConfigurationHeaderError = 10,
+ NoInstructionsError = 11,
+ InstructionNotForClaimsError = 12,
+ UnauthorizedError = 13,
+ ClaimValueNotAuthorisedError = 14,
+ ScopeNotAuthorisedError = 15,
+ UserDoesNotHaveClaimError = 16,
+ DownstreamPathTemplateContainsSchemeError = 17,
+ DownstreamPathNullOrEmptyError = 18,
+ DownstreamSchemeNullOrEmptyError = 19,
+ DownstreamHostNullOrEmptyError = 20,
+ ServicesAreNullError = 21,
+ ServicesAreEmptyError = 22,
+ UnableToFindServiceDiscoveryProviderError = 23,
+ UnableToFindLoadBalancerError = 24,
+ RequestTimedOutError = 25,
+ UnableToFindQoSProviderError = 26,
+ UnmappableRequestError = 27,
+ RateLimitOptionsError = 28,
+ PathTemplateDoesntStartWithForwardSlash = 29,
+ FileValidationFailedError = 30,
+ UnableToFindDelegatingHandlerProviderError = 31,
+ CouldNotFindPlaceholderError = 32,
+ CouldNotFindAggregatorError = 33,
+ CannotAddPlaceholderError = 34,
+ CannotRemovePlaceholderError = 35,
+ QuotaExceededError = 36,
+ RequestCanceled = 37,
}
-}
+}
diff --git a/src/Ocelot/Headers/AddHeadersToRequest.cs b/src/Ocelot/Headers/AddHeadersToRequest.cs
index d24f549a..9b0afee7 100644
--- a/src/Ocelot/Headers/AddHeadersToRequest.cs
+++ b/src/Ocelot/Headers/AddHeadersToRequest.cs
@@ -1,17 +1,16 @@
namespace Ocelot.Headers
{
- using System.Collections.Generic;
- using System.Linq;
using Infrastructure;
using Logging;
- using Ocelot.Configuration;
- using Ocelot.Infrastructure.Claims.Parser;
- using Ocelot.Responses;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
+ using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
- using Ocelot.Middleware;
+ using Ocelot.Infrastructure.Claims.Parser;
using Ocelot.Request.Middleware;
+ using Ocelot.Responses;
+ using System.Collections.Generic;
+ using System.Linq;
public class AddHeadersToRequest : IAddHeadersToRequest
{
@@ -49,7 +48,7 @@
return new OkResponse();
}
-
+
public void SetHeadersOnDownstreamRequest(IEnumerable headers, HttpContext context)
{
var requestHeader = context.Request.Headers;
diff --git a/src/Ocelot/Headers/AddHeadersToResponse.cs b/src/Ocelot/Headers/AddHeadersToResponse.cs
index 7c440d6a..a4151860 100644
--- a/src/Ocelot/Headers/AddHeadersToResponse.cs
+++ b/src/Ocelot/Headers/AddHeadersToResponse.cs
@@ -1,11 +1,11 @@
namespace Ocelot.Headers
{
- using System.Collections.Generic;
using Ocelot.Configuration.Creator;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging;
using Ocelot.Middleware;
+ using System.Collections.Generic;
public class AddHeadersToResponse : IAddHeadersToResponse
{
@@ -20,13 +20,13 @@ namespace Ocelot.Headers
public void Add(List addHeaders, DownstreamResponse response)
{
- foreach(var add in addHeaders)
+ foreach (var add in addHeaders)
{
- if(add.Value.StartsWith('{') && add.Value.EndsWith('}'))
+ if (add.Value.StartsWith('{') && add.Value.EndsWith('}'))
{
var value = _placeholders.Get(add.Value);
-
- if(value.IsError)
+
+ if (value.IsError)
{
_logger.LogWarning($"Unable to add header to response {add.Key}: {add.Value}");
continue;
diff --git a/src/Ocelot/Headers/HttpContextRequestHeaderReplacer.cs b/src/Ocelot/Headers/HttpContextRequestHeaderReplacer.cs
index 2323258a..6709231d 100644
--- a/src/Ocelot/Headers/HttpContextRequestHeaderReplacer.cs
+++ b/src/Ocelot/Headers/HttpContextRequestHeaderReplacer.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.Headers
{
@@ -11,7 +11,7 @@ namespace Ocelot.Headers
{
foreach (var f in fAndRs)
{
- if(context.Request.Headers.TryGetValue(f.Key, out var values))
+ if (context.Request.Headers.TryGetValue(f.Key, out var values))
{
var replaced = values[f.Index].Replace(f.Find, f.Replace);
context.Request.Headers.Remove(f.Key);
diff --git a/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs b/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs
index eb88af7a..a6992bf1 100644
--- a/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs
+++ b/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Headers
{
- using System.Collections.Generic;
- using System.Linq;
using Ocelot.Configuration;
using Ocelot.Infrastructure;
using Ocelot.Infrastructure.Extensions;
using Ocelot.Middleware;
using Ocelot.Responses;
+ using System.Collections.Generic;
+ using System.Linq;
public class HttpResponseHeaderReplacer : IHttpResponseHeaderReplacer
{
@@ -27,12 +27,12 @@ namespace Ocelot.Headers
var dict = response.Headers.ToDictionary(x => x.Key);
//if the response headers contain a matching find and replace
- if(dict.TryGetValue(f.Key, out var values))
+ if (dict.TryGetValue(f.Key, out var values))
{
//check to see if it is a placeholder in the find...
var placeholderValue = _placeholders.Get(f.Find, request);
- if(!placeholderValue.IsError)
+ if (!placeholderValue.IsError)
{
//if it is we need to get the value of the placeholder
var replaced = values.Values.ToList()[f.Index].Replace(placeholderValue.Data, f.Replace.LastCharAsForwardSlash());
diff --git a/src/Ocelot/Headers/IAddHeadersToRequest.cs b/src/Ocelot/Headers/IAddHeadersToRequest.cs
index a0afb0c0..9abbb3b4 100644
--- a/src/Ocelot/Headers/IAddHeadersToRequest.cs
+++ b/src/Ocelot/Headers/IAddHeadersToRequest.cs
@@ -2,18 +2,16 @@
namespace Ocelot.Headers
{
- using System.Collections.Generic;
- using System.Net.Http;
-
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
- using Ocelot.Infrastructure.RequestData;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
+ using System.Collections.Generic;
public interface IAddHeadersToRequest
{
Response SetHeadersOnDownstreamRequest(List claimsToThings, IEnumerable claims, DownstreamRequest downstreamRequest);
+
void SetHeadersOnDownstreamRequest(IEnumerable headers, HttpContext context);
}
-}
+}
diff --git a/src/Ocelot/Headers/IAddHeadersToResponse.cs b/src/Ocelot/Headers/IAddHeadersToResponse.cs
index 210ddd32..bbd37f4d 100644
--- a/src/Ocelot/Headers/IAddHeadersToResponse.cs
+++ b/src/Ocelot/Headers/IAddHeadersToResponse.cs
@@ -2,9 +2,8 @@ using Ocelot.Middleware;
namespace Ocelot.Headers
{
- using System.Collections.Generic;
using Ocelot.Configuration.Creator;
- using Ocelot.Middleware.Multiplexer;
+ using System.Collections.Generic;
public interface IAddHeadersToResponse
{
diff --git a/src/Ocelot/Headers/IHttpContextRequestHeaderReplacer.cs b/src/Ocelot/Headers/IHttpContextRequestHeaderReplacer.cs
index 5c985cfe..ba5ba348 100644
--- a/src/Ocelot/Headers/IHttpContextRequestHeaderReplacer.cs
+++ b/src/Ocelot/Headers/IHttpContextRequestHeaderReplacer.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.Headers
{
@@ -9,4 +9,4 @@ namespace Ocelot.Headers
{
Response Replace(HttpContext context, List fAndRs);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Headers/IHttpResponseHeaderReplacer.cs b/src/Ocelot/Headers/IHttpResponseHeaderReplacer.cs
index 7a180196..5ef5c84c 100644
--- a/src/Ocelot/Headers/IHttpResponseHeaderReplacer.cs
+++ b/src/Ocelot/Headers/IHttpResponseHeaderReplacer.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Headers
{
- using System.Collections.Generic;
using Ocelot.Configuration;
using Ocelot.Middleware;
using Ocelot.Responses;
+ using System.Collections.Generic;
public interface IHttpResponseHeaderReplacer
{
Response Replace(DownstreamContext context, List fAndRs);
}
-}
+}
diff --git a/src/Ocelot/Headers/IRemoveOutputHeaders.cs b/src/Ocelot/Headers/IRemoveOutputHeaders.cs
index 8c081c3b..bf2f7ff4 100644
--- a/src/Ocelot/Headers/IRemoveOutputHeaders.cs
+++ b/src/Ocelot/Headers/IRemoveOutputHeaders.cs
@@ -1,7 +1,6 @@
-using System.Collections.Generic;
-using Ocelot.Middleware;
-using Ocelot.Middleware.Multiplexer;
+using Ocelot.Middleware;
using Ocelot.Responses;
+using System.Collections.Generic;
namespace Ocelot.Headers
{
@@ -9,4 +8,4 @@ namespace Ocelot.Headers
{
Response Remove(List headers);
}
-}
+}
diff --git a/src/Ocelot/Headers/Middleware/ClaimsToHeadersMiddleware.cs b/src/Ocelot/Headers/Middleware/ClaimsToHeadersMiddleware.cs
index 1faf4fa6..e45bb4bb 100644
--- a/src/Ocelot/Headers/Middleware/ClaimsToHeadersMiddleware.cs
+++ b/src/Ocelot/Headers/Middleware/ClaimsToHeadersMiddleware.cs
@@ -1,10 +1,7 @@
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-using Ocelot.DownstreamRouteFinder.Middleware;
-using Ocelot.Infrastructure.RequestData;
-using Ocelot.Logging;
+using Ocelot.Logging;
using Ocelot.Middleware;
+using System.Linq;
+using System.Threading.Tasks;
namespace Ocelot.Headers.Middleware
{
@@ -15,8 +12,8 @@ namespace Ocelot.Headers.Middleware
public ClaimsToHeadersMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
- IAddHeadersToRequest addHeadersToRequest)
- :base(loggerFactory.CreateLogger())
+ IAddHeadersToRequest addHeadersToRequest)
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_addHeadersToRequest = addHeadersToRequest;
diff --git a/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddleware.cs b/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddleware.cs
index 4ac0fc8c..79684385 100644
--- a/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddleware.cs
+++ b/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddleware.cs
@@ -1,6 +1,6 @@
-using System.Threading.Tasks;
using Ocelot.Logging;
using Ocelot.Middleware;
+using System.Threading.Tasks;
namespace Ocelot.Headers.Middleware
{
@@ -17,8 +17,8 @@ namespace Ocelot.Headers.Middleware
IHttpContextRequestHeaderReplacer preReplacer,
IHttpResponseHeaderReplacer postReplacer,
IAddHeadersToResponse addHeadersToResponse,
- IAddHeadersToRequest addHeadersToRequest)
- :base(loggerFactory.CreateLogger())
+ IAddHeadersToRequest addHeadersToRequest)
+ : base(loggerFactory.CreateLogger())
{
_addHeadersToResponse = addHeadersToResponse;
_addHeadersToRequest = addHeadersToRequest;
@@ -38,7 +38,7 @@ namespace Ocelot.Headers.Middleware
await _next.Invoke(context);
- if(context.IsError)
+ if (context.IsError)
{
return;
}
diff --git a/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddlewareExtensions.cs b/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddlewareExtensions.cs
index 46bb84dc..4cfec462 100644
--- a/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddlewareExtensions.cs
+++ b/src/Ocelot/Headers/Middleware/HttpHeadersTransformationMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Headers.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Headers/RemoveOutputHeaders.cs b/src/Ocelot/Headers/RemoveOutputHeaders.cs
index 2664b696..82cd0051 100644
--- a/src/Ocelot/Headers/RemoveOutputHeaders.cs
+++ b/src/Ocelot/Headers/RemoveOutputHeaders.cs
@@ -1,8 +1,7 @@
+using Ocelot.Middleware;
+using Ocelot.Responses;
using System.Collections.Generic;
using System.Linq;
-using Ocelot.Middleware;
-using Ocelot.Middleware.Multiplexer;
-using Ocelot.Responses;
namespace Ocelot.Headers
{
@@ -13,7 +12,7 @@ namespace Ocelot.Headers
/// in a given context such as transfer encoding chunked when ASP.NET is not
/// returning the response in this manner
///
- private readonly string[] _unsupportedRequestHeaders =
+ private readonly string[] _unsupportedRequestHeaders =
{
"Transfer-Encoding"
};
@@ -24,4 +23,4 @@ namespace Ocelot.Headers
return new OkResponse();
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/CannotAddPlaceholderError.cs b/src/Ocelot/Infrastructure/CannotAddPlaceholderError.cs
index 93ca6857..5ff14542 100644
--- a/src/Ocelot/Infrastructure/CannotAddPlaceholderError.cs
+++ b/src/Ocelot/Infrastructure/CannotAddPlaceholderError.cs
@@ -9,4 +9,4 @@ namespace Ocelot.Infrastructure
{
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/Claims/Parser/CannotFindClaimError.cs b/src/Ocelot/Infrastructure/Claims/Parser/CannotFindClaimError.cs
index 5314d394..302bba06 100644
--- a/src/Ocelot/Infrastructure/Claims/Parser/CannotFindClaimError.cs
+++ b/src/Ocelot/Infrastructure/Claims/Parser/CannotFindClaimError.cs
@@ -4,9 +4,9 @@
public class CannotFindClaimError : Error
{
- public CannotFindClaimError(string message)
+ public CannotFindClaimError(string message)
: base(message, OcelotErrorCode.CannotFindClaimError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/Claims/Parser/IClaimsParser.cs b/src/Ocelot/Infrastructure/Claims/Parser/IClaimsParser.cs
index 1575ba20..05ec4f5d 100644
--- a/src/Ocelot/Infrastructure/Claims/Parser/IClaimsParser.cs
+++ b/src/Ocelot/Infrastructure/Claims/Parser/IClaimsParser.cs
@@ -1,12 +1,13 @@
namespace Ocelot.Infrastructure.Claims.Parser
{
+ using Responses;
using System.Collections.Generic;
using System.Security.Claims;
- using Responses;
public interface IClaimsParser
{
Response GetValue(IEnumerable claims, string key, string delimiter, int index);
+
Response> GetValuesByClaimType(IEnumerable claims, string claimType);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Infrastructure/CouldNotFindPlaceholderError.cs b/src/Ocelot/Infrastructure/CouldNotFindPlaceholderError.cs
index c6214e83..5c7121aa 100644
--- a/src/Ocelot/Infrastructure/CouldNotFindPlaceholderError.cs
+++ b/src/Ocelot/Infrastructure/CouldNotFindPlaceholderError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.Infrastructure
{
public class CouldNotFindPlaceholderError : Error
{
- public CouldNotFindPlaceholderError(string placeholder)
+ public CouldNotFindPlaceholderError(string placeholder)
: base($"Unable to find placeholder called {placeholder}", OcelotErrorCode.CouldNotFindPlaceholderError)
- {
- }
+ {
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Infrastructure/Extensions/ErrorListExtensions.cs b/src/Ocelot/Infrastructure/Extensions/ErrorListExtensions.cs
index 9c06d607..5d9f00f1 100644
--- a/src/Ocelot/Infrastructure/Extensions/ErrorListExtensions.cs
+++ b/src/Ocelot/Infrastructure/Extensions/ErrorListExtensions.cs
@@ -1,9 +1,6 @@
-using System;
+using Ocelot.Errors;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using Microsoft.Extensions.Primitives;
-using Ocelot.Errors;
namespace Ocelot.Infrastructure.Extensions
{
@@ -13,6 +10,6 @@ namespace Ocelot.Infrastructure.Extensions
{
var listOfErrorStrings = errors.Select(x => "Error Code: " + x.Code.ToString() + " Message: " + x.Message);
return string.Join(" ", listOfErrorStrings);
- }
- }
-}
+ }
+ }
+}
diff --git a/src/Ocelot/Infrastructure/Extensions/StringExtensions.cs b/src/Ocelot/Infrastructure/Extensions/StringExtensions.cs
index 743c8c9e..099d3252 100644
--- a/src/Ocelot/Infrastructure/Extensions/StringExtensions.cs
+++ b/src/Ocelot/Infrastructure/Extensions/StringExtensions.cs
@@ -22,7 +22,7 @@ namespace Ocelot.Infrastructure.Extensions
public static string LastCharAsForwardSlash(this string source)
{
- if(source.EndsWith('/'))
+ if (source.EndsWith('/'))
{
return source;
}
@@ -30,4 +30,4 @@ namespace Ocelot.Infrastructure.Extensions
return $"{source}/";
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Infrastructure/IBus.cs b/src/Ocelot/Infrastructure/IBus.cs
index 0fc227dd..5aa183d2 100644
--- a/src/Ocelot/Infrastructure/IBus.cs
+++ b/src/Ocelot/Infrastructure/IBus.cs
@@ -4,7 +4,8 @@ namespace Ocelot.Infrastructure
{
public interface IBus
{
- void Subscribe(Action action);
+ void Subscribe(Action action);
+
void Publish(T message, int delay);
}
}
diff --git a/src/Ocelot/Infrastructure/IPlaceholders.cs b/src/Ocelot/Infrastructure/IPlaceholders.cs
index 24b8e2ae..9d4b39ec 100644
--- a/src/Ocelot/Infrastructure/IPlaceholders.cs
+++ b/src/Ocelot/Infrastructure/IPlaceholders.cs
@@ -1,15 +1,17 @@
-using System;
-using System.Net.Http;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
+using System;
namespace Ocelot.Infrastructure
{
public interface IPlaceholders
{
Response Get(string key);
+
Response Get(string key, DownstreamRequest request);
+
Response Add(string key, Func> func);
+
Response Remove(string key);
}
}
diff --git a/src/Ocelot/Infrastructure/InMemoryBus.cs b/src/Ocelot/Infrastructure/InMemoryBus.cs
index c4dcc7a2..96ed9285 100644
--- a/src/Ocelot/Infrastructure/InMemoryBus.cs
+++ b/src/Ocelot/Infrastructure/InMemoryBus.cs
@@ -33,7 +33,7 @@ namespace Ocelot.Infrastructure
private async Task Process()
{
- foreach(var delayedMessage in _queue.GetConsumingEnumerable())
+ foreach (var delayedMessage in _queue.GetConsumingEnumerable())
{
await Task.Delay(delayedMessage.Delay);
diff --git a/src/Ocelot/Infrastructure/Placeholders.cs b/src/Ocelot/Infrastructure/Placeholders.cs
index 4069eb26..3c319e6d 100644
--- a/src/Ocelot/Infrastructure/Placeholders.cs
+++ b/src/Ocelot/Infrastructure/Placeholders.cs
@@ -1,12 +1,12 @@
namespace Ocelot.Infrastructure
{
- using System;
- using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
using Ocelot.Request.Middleware;
using Ocelot.Responses;
+ using System;
+ using System.Collections.Generic;
public class Placeholders : IPlaceholders
{
diff --git a/src/Ocelot/Infrastructure/RequestData/CannotAddDataError.cs b/src/Ocelot/Infrastructure/RequestData/CannotAddDataError.cs
index b96db870..e411f0d4 100644
--- a/src/Ocelot/Infrastructure/RequestData/CannotAddDataError.cs
+++ b/src/Ocelot/Infrastructure/RequestData/CannotAddDataError.cs
@@ -8,4 +8,4 @@ namespace Ocelot.Infrastructure.RequestData
{
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/RequestData/CannotFindDataError.cs b/src/Ocelot/Infrastructure/RequestData/CannotFindDataError.cs
index d80230ea..907742df 100644
--- a/src/Ocelot/Infrastructure/RequestData/CannotFindDataError.cs
+++ b/src/Ocelot/Infrastructure/RequestData/CannotFindDataError.cs
@@ -8,4 +8,4 @@ namespace Ocelot.Infrastructure.RequestData
{
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/RequestData/HttpDataRepository.cs b/src/Ocelot/Infrastructure/RequestData/HttpDataRepository.cs
index ec2ce4e0..c14a1b78 100644
--- a/src/Ocelot/Infrastructure/RequestData/HttpDataRepository.cs
+++ b/src/Ocelot/Infrastructure/RequestData/HttpDataRepository.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Http;
-using Ocelot.Errors;
+using Microsoft.AspNetCore.Http;
using Ocelot.Responses;
+using System;
namespace Ocelot.Infrastructure.RequestData
{
@@ -45,18 +43,18 @@ namespace Ocelot.Infrastructure.RequestData
{
object obj;
- if(_httpContextAccessor.HttpContext == null || _httpContextAccessor.HttpContext.Items == null)
+ if (_httpContextAccessor.HttpContext == null || _httpContextAccessor.HttpContext.Items == null)
{
return new ErrorResponse(new CannotFindDataError($"Unable to find data for key: {key} because HttpContext or HttpContext.Items is null"));
}
- if(_httpContextAccessor.HttpContext.Items.TryGetValue(key, out obj))
+ if (_httpContextAccessor.HttpContext.Items.TryGetValue(key, out obj))
{
- var data = (T) obj;
+ var data = (T)obj;
return new OkResponse(data);
}
return new ErrorResponse(new CannotFindDataError($"Unable to find data for key: {key}"));
}
}
-}
+}
diff --git a/src/Ocelot/Infrastructure/RequestData/IRequestScopedDataRepository.cs b/src/Ocelot/Infrastructure/RequestData/IRequestScopedDataRepository.cs
index 1431b446..47443ed9 100644
--- a/src/Ocelot/Infrastructure/RequestData/IRequestScopedDataRepository.cs
+++ b/src/Ocelot/Infrastructure/RequestData/IRequestScopedDataRepository.cs
@@ -5,7 +5,9 @@ namespace Ocelot.Infrastructure.RequestData
public interface IRequestScopedDataRepository
{
Response Add(string key, T value);
+
Response Update(string key, T value);
+
Response Get(string key);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/CookieStickySessions.cs b/src/Ocelot/LoadBalancer/LoadBalancers/CookieStickySessions.cs
index 357ea84e..775ed7ce 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/CookieStickySessions.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/CookieStickySessions.cs
@@ -1,13 +1,11 @@
namespace Ocelot.LoadBalancer.LoadBalancers
{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Threading;
- using System.Threading.Tasks;
using Ocelot.Infrastructure;
using Ocelot.Middleware;
using Responses;
+ using System;
+ using System.Collections.Concurrent;
+ using System.Threading.Tasks;
using Values;
public class CookieStickySessions : ILoadBalancer
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancer.cs b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancer.cs
index d56367b2..4f8ec2b7 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancer.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancer.cs
@@ -1,13 +1,14 @@
-using System.Threading.Tasks;
using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
+using System.Threading.Tasks;
namespace Ocelot.LoadBalancer.LoadBalancers
{
public interface ILoadBalancer
{
Task> Lease(DownstreamContext context);
+
void Release(ServiceHostAndPort hostAndPort);
}
}
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerFactory.cs b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerFactory.cs
index 7ca857f5..df115c41 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerFactory.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerFactory.cs
@@ -1,8 +1,8 @@
namespace Ocelot.LoadBalancer.LoadBalancers
{
- using System.Threading.Tasks;
using Ocelot.Configuration;
using Ocelot.Responses;
+ using System.Threading.Tasks;
public interface ILoadBalancerFactory
{
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerHouse.cs b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerHouse.cs
index 7f8d7381..92eb0e9e 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerHouse.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/ILoadBalancerHouse.cs
@@ -1,6 +1,6 @@
-using System.Threading.Tasks;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.Responses;
+using System.Threading.Tasks;
namespace Ocelot.LoadBalancer.LoadBalancers
{
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs b/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs
index 2713d44b..94bfd97e 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs
@@ -13,4 +13,4 @@ namespace Ocelot.LoadBalancer.LoadBalancers
public ServiceHostAndPort HostAndPort { get; private set; }
public int Connections { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/LeastConnection.cs b/src/Ocelot/LoadBalancer/LoadBalancers/LeastConnection.cs
index 59f260ca..ee7c0fdd 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/LeastConnection.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/LeastConnection.cs
@@ -1,11 +1,10 @@
-using System;
+using Ocelot.Middleware;
+using Ocelot.Responses;
+using Ocelot.Values;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Ocelot.Errors;
-using Ocelot.Middleware;
-using Ocelot.Responses;
-using Ocelot.Values;
namespace Ocelot.LoadBalancer.LoadBalancers
{
@@ -29,7 +28,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
if (services == null)
{
- return new ErrorResponse(new ServicesAreNullError($"services were null for {_serviceName}") );
+ return new ErrorResponse(new ServicesAreNullError($"services were null for {_serviceName}"));
}
if (!services.Any())
@@ -37,8 +36,8 @@ namespace Ocelot.LoadBalancer.LoadBalancers
return new ErrorResponse(new ServicesAreEmptyError($"services were empty for {_serviceName}"));
}
- lock(_syncLock)
- {
+ lock (_syncLock)
+ {
//todo - maybe this should be moved somewhere else...? Maybe on a repeater on seperate thread? loop every second and update or something?
UpdateServices(services);
@@ -49,14 +48,14 @@ namespace Ocelot.LoadBalancer.LoadBalancers
leaseWithLeastConnections = AddConnection(leaseWithLeastConnections);
_leases.Add(leaseWithLeastConnections);
-
+
return new OkResponse(new ServiceHostAndPort(leaseWithLeastConnections.HostAndPort.DownstreamHost, leaseWithLeastConnections.HostAndPort.DownstreamPort));
}
}
public void Release(ServiceHostAndPort hostAndPort)
{
- lock(_syncLock)
+ lock (_syncLock)
{
var matchingLease = _leases.FirstOrDefault(l => l.HostAndPort.DownstreamHost == hostAndPort.DownstreamHost
&& l.HostAndPort.DownstreamPort == hostAndPort.DownstreamPort);
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/LoadBalancerFactory.cs b/src/Ocelot/LoadBalancer/LoadBalancers/LoadBalancerFactory.cs
index dce8d405..12725a57 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/LoadBalancerFactory.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/LoadBalancerFactory.cs
@@ -1,8 +1,8 @@
-using System.Threading.Tasks;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.Infrastructure;
using Ocelot.Responses;
using Ocelot.ServiceDiscovery;
+using System.Threading.Tasks;
namespace Ocelot.LoadBalancer.LoadBalancers
{
@@ -16,10 +16,10 @@ namespace Ocelot.LoadBalancer.LoadBalancers
}
public async Task> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config)
- {
+ {
var response = _serviceProviderFactory.Get(config, reRoute);
- if(response.IsError)
+ if (response.IsError)
{
return new ErrorResponse(response.Errors);
}
@@ -30,12 +30,15 @@ namespace Ocelot.LoadBalancer.LoadBalancers
{
case nameof(RoundRobin):
return new OkResponse(new RoundRobin(async () => await serviceProvider.Get()));
+
case nameof(LeastConnection):
return new OkResponse(new LeastConnection(async () => await serviceProvider.Get(), reRoute.ServiceName));
+
case nameof(CookieStickySessions):
var loadBalancer = new RoundRobin(async () => await serviceProvider.Get());
var bus = new InMemoryBus();
return new OkResponse(new CookieStickySessions(loadBalancer, reRoute.LoadBalancerOptions.Key, reRoute.LoadBalancerOptions.ExpiryInMs, bus));
+
default:
return new OkResponse(new NoLoadBalancer(async () => await serviceProvider.Get()));
}
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/NoLoadBalancer.cs b/src/Ocelot/LoadBalancer/LoadBalancers/NoLoadBalancer.cs
index c24a50d2..112fd5bb 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/NoLoadBalancer.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/NoLoadBalancer.cs
@@ -1,10 +1,10 @@
-using System;
+using Ocelot.Middleware;
+using Ocelot.Responses;
+using Ocelot.Values;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Ocelot.Middleware;
-using Ocelot.Responses;
-using Ocelot.Values;
namespace Ocelot.LoadBalancer.LoadBalancers
{
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs b/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs
index b130f6fe..3500efe0 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs
@@ -1,9 +1,9 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
+using Ocelot.Middleware;
using Ocelot.Responses;
using Ocelot.Values;
using System;
-using Ocelot.Middleware;
+using System.Collections.Generic;
+using System.Threading.Tasks;
namespace Ocelot.LoadBalancer.LoadBalancers
{
@@ -22,7 +22,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
public async Task> Lease(DownstreamContext downstreamContext)
{
var services = await _services();
- lock(_lock)
+ lock (_lock)
{
if (_last >= services.Count)
{
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/StickySession.cs b/src/Ocelot/LoadBalancer/LoadBalancers/StickySession.cs
index bce476c0..6f487ec7 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/StickySession.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/StickySession.cs
@@ -1,5 +1,5 @@
-using System;
using Ocelot.Values;
+using System;
namespace Ocelot.LoadBalancer.LoadBalancers
{
@@ -13,9 +13,9 @@ namespace Ocelot.LoadBalancer.LoadBalancers
}
public ServiceHostAndPort HostAndPort { get; }
-
+
public DateTime Expiry { get; }
- public string Key {get;}
+ public string Key { get; }
}
}
diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/UnableToFindLoadBalancerError.cs b/src/Ocelot/LoadBalancer/LoadBalancers/UnableToFindLoadBalancerError.cs
index 8ce7bcd4..04a305f5 100644
--- a/src/Ocelot/LoadBalancer/LoadBalancers/UnableToFindLoadBalancerError.cs
+++ b/src/Ocelot/LoadBalancer/LoadBalancers/UnableToFindLoadBalancerError.cs
@@ -4,9 +4,9 @@ namespace Ocelot.LoadBalancer.LoadBalancers
{
public class UnableToFindLoadBalancerError : Errors.Error
{
- public UnableToFindLoadBalancerError(string message)
+ public UnableToFindLoadBalancerError(string message)
: base(message, OcelotErrorCode.UnableToFindLoadBalancerError)
{
}
}
-}
+}
diff --git a/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddleware.cs b/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddleware.cs
index 9568b9cf..22456430 100644
--- a/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddleware.cs
+++ b/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddleware.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Threading.Tasks;
-using Ocelot.LoadBalancer.LoadBalancers;
+using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.Logging;
using Ocelot.Middleware;
+using System;
+using System.Threading.Tasks;
namespace Ocelot.LoadBalancer.Middleware
{
@@ -13,8 +13,8 @@ namespace Ocelot.LoadBalancer.Middleware
public LoadBalancingMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
- ILoadBalancerHouse loadBalancerHouse)
- :base(loggerFactory.CreateLogger())
+ ILoadBalancerHouse loadBalancerHouse)
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_loadBalancerHouse = loadBalancerHouse;
@@ -23,7 +23,7 @@ namespace Ocelot.LoadBalancer.Middleware
public async Task Invoke(DownstreamContext context)
{
var loadBalancer = await _loadBalancerHouse.Get(context.DownstreamReRoute, context.Configuration.ServiceProviderConfiguration);
- if(loadBalancer.IsError)
+ if (loadBalancer.IsError)
{
Logger.LogDebug("there was an error retriving the loadbalancer, setting pipeline error");
SetPipelineError(context, loadBalancer.Errors);
@@ -31,7 +31,7 @@ namespace Ocelot.LoadBalancer.Middleware
}
var hostAndPort = await loadBalancer.Data.Lease(context);
- if(hostAndPort.IsError)
+ if (hostAndPort.IsError)
{
Logger.LogDebug("there was an error leasing the loadbalancer, setting pipeline error");
SetPipelineError(context, hostAndPort.Errors);
diff --git a/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddlewareExtensions.cs b/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddlewareExtensions.cs
index a2da1060..8f6558c7 100644
--- a/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddlewareExtensions.cs
+++ b/src/Ocelot/LoadBalancer/Middleware/LoadBalancingMiddlewareExtensions.cs
@@ -2,12 +2,12 @@ using Microsoft.AspNetCore.Builder;
using Ocelot.Middleware.Pipeline;
namespace Ocelot.LoadBalancer.Middleware
-{
- public static class LoadBalancingMiddlewareExtensions
+{
+ public static class LoadBalancingMiddlewareExtensions
{
public static IOcelotPipelineBuilder UseLoadBalancingMiddleware(this IOcelotPipelineBuilder builder)
{
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Logging/AspDotNetLogger.cs b/src/Ocelot/Logging/AspDotNetLogger.cs
index 5ee04e13..598cbdd0 100644
--- a/src/Ocelot/Logging/AspDotNetLogger.cs
+++ b/src/Ocelot/Logging/AspDotNetLogger.cs
@@ -1,6 +1,6 @@
-using System;
using Microsoft.Extensions.Logging;
using Ocelot.Infrastructure.RequestData;
+using System;
namespace Ocelot.Logging
{
@@ -16,21 +16,21 @@ namespace Ocelot.Logging
}
public void LogTrace(string message)
- {
+ {
var requestId = GetOcelotRequestId();
var previousRequestId = GetOcelotPreviousRequestId();
_logger.LogTrace("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
}
public void LogDebug(string message)
- {
+ {
var requestId = GetOcelotRequestId();
var previousRequestId = GetOcelotPreviousRequestId();
_logger.LogDebug("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
}
public void LogInformation(string message)
- {
+ {
var requestId = GetOcelotRequestId();
var previousRequestId = GetOcelotPreviousRequestId();
_logger.LogInformation("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
@@ -81,4 +81,4 @@ namespace Ocelot.Logging
return requestId.Data;
}
}
-}
+}
diff --git a/src/Ocelot/Logging/IOcelotLogger.cs b/src/Ocelot/Logging/IOcelotLogger.cs
index 7d1c1205..9ffced20 100644
--- a/src/Ocelot/Logging/IOcelotLogger.cs
+++ b/src/Ocelot/Logging/IOcelotLogger.cs
@@ -8,10 +8,15 @@ namespace Ocelot.Logging
public interface IOcelotLogger
{
void LogTrace(string message);
+
void LogDebug(string message);
+
void LogInformation(string message);
+
void LogWarning(string message);
+
void LogError(string message, Exception exception);
+
void LogCritical(string message, Exception exception);
}
}
diff --git a/src/Ocelot/Logging/IOcelotLoggerFactory.cs b/src/Ocelot/Logging/IOcelotLoggerFactory.cs
index 2407afcd..7b7c6c39 100644
--- a/src/Ocelot/Logging/IOcelotLoggerFactory.cs
+++ b/src/Ocelot/Logging/IOcelotLoggerFactory.cs
@@ -4,4 +4,4 @@
{
IOcelotLogger CreateLogger();
}
-}
+}
diff --git a/src/Ocelot/Logging/ITracer.cs b/src/Ocelot/Logging/ITracer.cs
index 9e035d75..6dbf9149 100644
--- a/src/Ocelot/Logging/ITracer.cs
+++ b/src/Ocelot/Logging/ITracer.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Logging
{
+ using Microsoft.AspNetCore.Http;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
- using Microsoft.AspNetCore.Http;
public interface ITracer
{
diff --git a/src/Ocelot/Logging/OcelotDiagnosticListener.cs b/src/Ocelot/Logging/OcelotDiagnosticListener.cs
index 8a5c0215..09beac49 100644
--- a/src/Ocelot/Logging/OcelotDiagnosticListener.cs
+++ b/src/Ocelot/Logging/OcelotDiagnosticListener.cs
@@ -1,8 +1,8 @@
-using System;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.DiagnosticAdapter;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DiagnosticAdapter;
using Ocelot.Middleware;
+using System;
namespace Ocelot.Logging
{
diff --git a/src/Ocelot/Middleware/BaseUrlFinder.cs b/src/Ocelot/Middleware/BaseUrlFinder.cs
index fe3acea7..d65fb769 100644
--- a/src/Ocelot/Middleware/BaseUrlFinder.cs
+++ b/src/Ocelot/Middleware/BaseUrlFinder.cs
@@ -20,4 +20,4 @@ namespace Ocelot.Middleware
return string.IsNullOrEmpty(baseUrl) ? _config.GetValue("BaseUrl", "http://localhost:5000") : baseUrl;
}
}
-}
+}
diff --git a/src/Ocelot/Middleware/DownstreamContext.cs b/src/Ocelot/Middleware/DownstreamContext.cs
index eb21b4bb..5a2dc34a 100644
--- a/src/Ocelot/Middleware/DownstreamContext.cs
+++ b/src/Ocelot/Middleware/DownstreamContext.cs
@@ -1,9 +1,9 @@
-using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Errors;
using Ocelot.Request.Middleware;
+using System.Collections.Generic;
namespace Ocelot.Middleware
{
diff --git a/src/Ocelot/Middleware/DownstreamResponse.cs b/src/Ocelot/Middleware/DownstreamResponse.cs
index c58a5198..3a27f6c9 100644
--- a/src/Ocelot/Middleware/DownstreamResponse.cs
+++ b/src/Ocelot/Middleware/DownstreamResponse.cs
@@ -16,18 +16,18 @@ namespace Ocelot.Middleware
}
public DownstreamResponse(HttpResponseMessage response)
- :this(response.Content, response.StatusCode, response.Headers.Select(x => new Header(x.Key, x.Value)).ToList(), response.ReasonPhrase)
+ : this(response.Content, response.StatusCode, response.Headers.Select(x => new Header(x.Key, x.Value)).ToList(), response.ReasonPhrase)
{
}
public DownstreamResponse(HttpContent content, HttpStatusCode statusCode, IEnumerable>> headers, string reasonPhrase)
- :this(content, statusCode, headers.Select(x => new Header(x.Key, x.Value)).ToList(), reasonPhrase)
+ : this(content, statusCode, headers.Select(x => new Header(x.Key, x.Value)).ToList(), reasonPhrase)
{
}
public HttpContent Content { get; }
public HttpStatusCode StatusCode { get; }
public List Headers { get; }
- public string ReasonPhrase {get;}
+ public string ReasonPhrase { get; }
}
}
diff --git a/src/Ocelot/Middleware/Multiplexer/CouldNotFindAggregatorError.cs b/src/Ocelot/Middleware/Multiplexer/CouldNotFindAggregatorError.cs
index 76a19d7c..e32109b7 100644
--- a/src/Ocelot/Middleware/Multiplexer/CouldNotFindAggregatorError.cs
+++ b/src/Ocelot/Middleware/Multiplexer/CouldNotFindAggregatorError.cs
@@ -4,7 +4,7 @@ namespace Ocelot.Middleware.Multiplexer
{
public class CouldNotFindAggregatorError : Error
{
- public CouldNotFindAggregatorError(string aggregator)
+ public CouldNotFindAggregatorError(string aggregator)
: base($"Could not find Aggregator: {aggregator}", OcelotErrorCode.CouldNotFindAggregatorError)
{
}
diff --git a/src/Ocelot/Middleware/Multiplexer/IMultiplexer.cs b/src/Ocelot/Middleware/Multiplexer/IMultiplexer.cs
index f3a2975d..57a724e2 100644
--- a/src/Ocelot/Middleware/Multiplexer/IMultiplexer.cs
+++ b/src/Ocelot/Middleware/Multiplexer/IMultiplexer.cs
@@ -1,5 +1,5 @@
-using System.Threading.Tasks;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
+using System.Threading.Tasks;
namespace Ocelot.Middleware.Multiplexer
{
diff --git a/src/Ocelot/Middleware/Multiplexer/IResponseAggregator.cs b/src/Ocelot/Middleware/Multiplexer/IResponseAggregator.cs
index 89f2b00b..bd56ca09 100644
--- a/src/Ocelot/Middleware/Multiplexer/IResponseAggregator.cs
+++ b/src/Ocelot/Middleware/Multiplexer/IResponseAggregator.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using Ocelot.Configuration;
+using System.Collections.Generic;
using System.Threading.Tasks;
-using Ocelot.Configuration;
namespace Ocelot.Middleware.Multiplexer
{
diff --git a/src/Ocelot/Middleware/Multiplexer/InMemoryResponseAggregatorFactory.cs b/src/Ocelot/Middleware/Multiplexer/InMemoryResponseAggregatorFactory.cs
index b9721e1b..ce426d86 100644
--- a/src/Ocelot/Middleware/Multiplexer/InMemoryResponseAggregatorFactory.cs
+++ b/src/Ocelot/Middleware/Multiplexer/InMemoryResponseAggregatorFactory.cs
@@ -15,7 +15,7 @@ namespace Ocelot.Middleware.Multiplexer
public IResponseAggregator Get(ReRoute reRoute)
{
- if(!string.IsNullOrEmpty(reRoute.Aggregator))
+ if (!string.IsNullOrEmpty(reRoute.Aggregator))
{
return _userDefined;
}
diff --git a/src/Ocelot/Middleware/Multiplexer/Multiplexer.cs b/src/Ocelot/Middleware/Multiplexer/Multiplexer.cs
index d61678e3..a49e20c1 100644
--- a/src/Ocelot/Middleware/Multiplexer/Multiplexer.cs
+++ b/src/Ocelot/Middleware/Multiplexer/Multiplexer.cs
@@ -1,9 +1,8 @@
-using System.Collections.Generic;
+using Ocelot.Configuration;
+using Ocelot.DownstreamRouteFinder.UrlMatcher;
+using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-using Ocelot.Configuration;
-using Ocelot.DownstreamRouteFinder.UrlMatcher;
namespace Ocelot.Middleware.Multiplexer
{
diff --git a/src/Ocelot/Middleware/Multiplexer/ServiceLocatorDefinedAggregatorProvider.cs b/src/Ocelot/Middleware/Multiplexer/ServiceLocatorDefinedAggregatorProvider.cs
index b7b85d26..c02a4bf7 100644
--- a/src/Ocelot/Middleware/Multiplexer/ServiceLocatorDefinedAggregatorProvider.cs
+++ b/src/Ocelot/Middleware/Multiplexer/ServiceLocatorDefinedAggregatorProvider.cs
@@ -1,9 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.Responses;
+using System;
+using System.Collections.Generic;
+using System.Linq;
namespace Ocelot.Middleware.Multiplexer
{
@@ -18,7 +18,7 @@ namespace Ocelot.Middleware.Multiplexer
public Response Get(ReRoute reRoute)
{
- if(_aggregators.ContainsKey(reRoute.Aggregator))
+ if (_aggregators.ContainsKey(reRoute.Aggregator))
{
return new OkResponse(_aggregators[reRoute.Aggregator]);
}
diff --git a/src/Ocelot/Middleware/Multiplexer/SimpleJsonResponseAggregator.cs b/src/Ocelot/Middleware/Multiplexer/SimpleJsonResponseAggregator.cs
index 8524519e..f03b52c5 100644
--- a/src/Ocelot/Middleware/Multiplexer/SimpleJsonResponseAggregator.cs
+++ b/src/Ocelot/Middleware/Multiplexer/SimpleJsonResponseAggregator.cs
@@ -1,11 +1,11 @@
-using System.Collections.Generic;
+using Ocelot.Configuration;
+using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
-using Ocelot.Configuration;
namespace Ocelot.Middleware.Multiplexer
{
diff --git a/src/Ocelot/Middleware/Multiplexer/UserDefinedResponseAggregator.cs b/src/Ocelot/Middleware/Multiplexer/UserDefinedResponseAggregator.cs
index 0080b60e..47c07c00 100644
--- a/src/Ocelot/Middleware/Multiplexer/UserDefinedResponseAggregator.cs
+++ b/src/Ocelot/Middleware/Multiplexer/UserDefinedResponseAggregator.cs
@@ -1,6 +1,6 @@
+using Ocelot.Configuration;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Ocelot.Configuration;
namespace Ocelot.Middleware.Multiplexer
{
diff --git a/src/Ocelot/Middleware/OcelotMiddleware.cs b/src/Ocelot/Middleware/OcelotMiddleware.cs
index fe51fd24..0bf57afc 100644
--- a/src/Ocelot/Middleware/OcelotMiddleware.cs
+++ b/src/Ocelot/Middleware/OcelotMiddleware.cs
@@ -1,11 +1,11 @@
-using System.Collections.Generic;
-using Ocelot.Errors;
+using Ocelot.Errors;
using Ocelot.Logging;
+using System.Collections.Generic;
namespace Ocelot.Middleware
{
public abstract class OcelotMiddleware
- {
+ {
protected OcelotMiddleware(IOcelotLogger logger)
{
Logger = logger;
@@ -18,7 +18,7 @@ namespace Ocelot.Middleware
public void SetPipelineError(DownstreamContext context, List errors)
{
- foreach(var error in errors)
+ foreach (var error in errors)
{
SetPipelineError(context, error);
}
@@ -30,4 +30,4 @@ namespace Ocelot.Middleware
context.Errors.Add(error);
}
}
-}
+}
diff --git a/src/Ocelot/Middleware/OcelotMiddlewareConfigurationDelegate.cs b/src/Ocelot/Middleware/OcelotMiddlewareConfigurationDelegate.cs
index f0dbb5c1..f5e2061d 100644
--- a/src/Ocelot/Middleware/OcelotMiddlewareConfigurationDelegate.cs
+++ b/src/Ocelot/Middleware/OcelotMiddlewareConfigurationDelegate.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Middleware
{
- using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
+ using System.Threading.Tasks;
public delegate Task OcelotMiddlewareConfigurationDelegate(IApplicationBuilder builder);
}
diff --git a/src/Ocelot/Middleware/Pipeline/IOcelotPipelineBuilder.cs b/src/Ocelot/Middleware/Pipeline/IOcelotPipelineBuilder.cs
index a10a2369..b7199e2b 100644
--- a/src/Ocelot/Middleware/Pipeline/IOcelotPipelineBuilder.cs
+++ b/src/Ocelot/Middleware/Pipeline/IOcelotPipelineBuilder.cs
@@ -9,8 +9,11 @@ namespace Ocelot.Middleware.Pipeline
public interface IOcelotPipelineBuilder
{
IServiceProvider ApplicationServices { get; }
+
IOcelotPipelineBuilder Use(Func middleware);
+
OcelotRequestDelegate Build();
+
IOcelotPipelineBuilder New();
}
}
diff --git a/src/Ocelot/Middleware/Pipeline/OcelotPipelineBuilder.cs b/src/Ocelot/Middleware/Pipeline/OcelotPipelineBuilder.cs
index 58f71122..5e3ee32e 100644
--- a/src/Ocelot/Middleware/Pipeline/OcelotPipelineBuilder.cs
+++ b/src/Ocelot/Middleware/Pipeline/OcelotPipelineBuilder.cs
@@ -19,7 +19,7 @@ namespace Ocelot.Middleware.Pipeline
_middlewares = new List>();
}
- public OcelotPipelineBuilder(IOcelotPipelineBuilder builder)
+ public OcelotPipelineBuilder(IOcelotPipelineBuilder builder)
{
ApplicationServices = builder.ApplicationServices;
_middlewares = new List>();
diff --git a/src/Ocelot/Middleware/Pipeline/OcelotPipelineExtensions.cs b/src/Ocelot/Middleware/Pipeline/OcelotPipelineExtensions.cs
index a35dc41f..b75a5b1d 100644
--- a/src/Ocelot/Middleware/Pipeline/OcelotPipelineExtensions.cs
+++ b/src/Ocelot/Middleware/Pipeline/OcelotPipelineExtensions.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Threading.Tasks;
-using Ocelot.Authentication.Middleware;
+using Ocelot.Authentication.Middleware;
using Ocelot.Authorisation.Middleware;
using Ocelot.Cache.Middleware;
using Ocelot.Claims.Middleware;
@@ -17,6 +15,8 @@ using Ocelot.RequestId.Middleware;
using Ocelot.Responder.Middleware;
using Ocelot.Security.Middleware;
using Ocelot.WebSockets.Middleware;
+using System;
+using System.Threading.Tasks;
namespace Ocelot.Middleware.Pipeline
{
@@ -96,7 +96,7 @@ namespace Ocelot.Middleware.Pipeline
// Allow pre authorisation logic. The idea being people might want to run something custom before what is built in.
builder.UseIfNotNull(pipelineConfiguration.PreAuthorisationMiddleware);
- // Now we have authenticated and done any claims transformation we
+ // Now we have authenticated and done any claims transformation we
// can authorise the request
// We allow the ocelot middleware to be overriden by whatever the
// user wants
@@ -124,7 +124,7 @@ namespace Ocelot.Middleware.Pipeline
// This takes the downstream route we retrieved earlier and replaces any placeholders with the variables that should be used
builder.UseDownstreamUrlCreatorMiddleware();
- // Not sure if this is the best place for this but we use the downstream url
+ // Not sure if this is the best place for this but we use the downstream url
// as the basis for our cache key.
builder.UseOutputCacheMiddleware();
diff --git a/src/Ocelot/Middleware/UnauthenticatedError.cs b/src/Ocelot/Middleware/UnauthenticatedError.cs
index d99d7503..f6ee444b 100644
--- a/src/Ocelot/Middleware/UnauthenticatedError.cs
+++ b/src/Ocelot/Middleware/UnauthenticatedError.cs
@@ -8,4 +8,4 @@ namespace Ocelot.Middleware
{
}
}
-}
+}
diff --git a/src/Ocelot/Ocelot.csproj b/src/Ocelot/Ocelot.csproj
index 3b0b9b34..b9d9d2ce 100644
--- a/src/Ocelot/Ocelot.csproj
+++ b/src/Ocelot/Ocelot.csproj
@@ -26,14 +26,14 @@
True
-
-
-
-
-
+
+
+
+
+
NU1701
-
+
all
diff --git a/src/Ocelot/Properties/AssemblyInfo.cs b/src/Ocelot/Properties/AssemblyInfo.cs
index cf28a510..c2a11a5b 100644
--- a/src/Ocelot/Properties/AssemblyInfo.cs
+++ b/src/Ocelot/Properties/AssemblyInfo.cs
@@ -15,4 +15,4 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("d6df4206-0dba-41d8-884d-c3e08290fdbb")]
+[assembly: Guid("d6df4206-0dba-41d8-884d-c3e08290fdbb")]
diff --git a/src/Ocelot/QueryStrings/AddQueriesToRequest.cs b/src/Ocelot/QueryStrings/AddQueriesToRequest.cs
index 3cc2abdf..3df7ffb7 100644
--- a/src/Ocelot/QueryStrings/AddQueriesToRequest.cs
+++ b/src/Ocelot/QueryStrings/AddQueriesToRequest.cs
@@ -1,14 +1,11 @@
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
using Ocelot.Configuration;
using Ocelot.Infrastructure.Claims.Parser;
-using Ocelot.Responses;
-using System.Security.Claims;
-using System.Net.Http;
-using System;
using Ocelot.Request.Middleware;
-using Microsoft.Extensions.Primitives;
+using Ocelot.Responses;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
using System.Text;
namespace Ocelot.QueryStrings
@@ -64,8 +61,8 @@ namespace Ocelot.QueryStrings
{
var builder = new StringBuilder();
- builder.Append("?");
-
+ builder.Append("?");
+
int outerCount = 0;
foreach (var query in queryDictionary)
@@ -74,13 +71,13 @@ namespace Ocelot.QueryStrings
{
builder.Append($"{query.Key}={query.Value[innerCount]}");
- if(innerCount < (query.Value.Count - 1))
+ if (innerCount < (query.Value.Count - 1))
{
builder.Append("&");
}
}
- if(outerCount < (queryDictionary.Count - 1))
+ if (outerCount < (queryDictionary.Count - 1))
{
builder.Append("&");
}
@@ -91,4 +88,4 @@ namespace Ocelot.QueryStrings
return builder.ToString();
}
}
-}
+}
diff --git a/src/Ocelot/QueryStrings/IAddQueriesToRequest.cs b/src/Ocelot/QueryStrings/IAddQueriesToRequest.cs
index bc017936..03c634ba 100644
--- a/src/Ocelot/QueryStrings/IAddQueriesToRequest.cs
+++ b/src/Ocelot/QueryStrings/IAddQueriesToRequest.cs
@@ -1,10 +1,8 @@
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Http;
-using Ocelot.Configuration;
-using Ocelot.Responses;
-using System.Net.Http;
-using System.Security.Claims;
+using Ocelot.Configuration;
using Ocelot.Request.Middleware;
+using Ocelot.Responses;
+using System.Collections.Generic;
+using System.Security.Claims;
namespace Ocelot.QueryStrings
{
@@ -12,4 +10,4 @@ namespace Ocelot.QueryStrings
{
Response SetQueriesOnDownstreamRequest(List claimsToThings, IEnumerable claims, DownstreamRequest downstreamRequest);
}
-}
+}
diff --git a/src/Ocelot/QueryStrings/Middleware/ClaimsToQueryStringMiddleware.cs b/src/Ocelot/QueryStrings/Middleware/ClaimsToQueryStringMiddleware.cs
index 6af29464..4e1a1218 100644
--- a/src/Ocelot/QueryStrings/Middleware/ClaimsToQueryStringMiddleware.cs
+++ b/src/Ocelot/QueryStrings/Middleware/ClaimsToQueryStringMiddleware.cs
@@ -1,12 +1,9 @@
namespace Ocelot.QueryStrings.Middleware
{
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Http;
- using Ocelot.DownstreamRouteFinder.Middleware;
- using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware;
+ using System.Linq;
+ using System.Threading.Tasks;
public class ClaimsToQueryStringMiddleware : OcelotMiddleware
{
@@ -15,7 +12,7 @@
public ClaimsToQueryStringMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
- IAddQueriesToRequest addQueriesToRequest)
+ IAddQueriesToRequest addQueriesToRequest)
: base(loggerFactory.CreateLogger())
{
_next = next;
diff --git a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs
index 65a04504..06393ddb 100644
--- a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs
+++ b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs
@@ -1,9 +1,6 @@
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
@@ -38,4 +35,4 @@ namespace Ocelot.RateLimit
return _core.ConvertToTimeSpan(timeSpan);
}
}
-}
+}
diff --git a/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs b/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs
index 91f933b7..d9eddfe3 100644
--- a/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs
+++ b/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs
@@ -1,9 +1,6 @@
using Microsoft.Extensions.Caching.Distributed;
using Newtonsoft.Json;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
@@ -43,4 +40,4 @@ namespace Ocelot.RateLimit
_memoryCache.Remove(id);
}
}
-}
+}
diff --git a/src/Ocelot/RateLimit/IRateLimitCounterHandler.cs b/src/Ocelot/RateLimit/IRateLimitCounterHandler.cs
index 5ab7a5da..e4b4da0d 100644
--- a/src/Ocelot/RateLimit/IRateLimitCounterHandler.cs
+++ b/src/Ocelot/RateLimit/IRateLimitCounterHandler.cs
@@ -1,15 +1,15 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
public interface IRateLimitCounterHandler
{
bool Exists(string id);
+
RateLimitCounter? Get(string id);
+
void Remove(string id);
+
void Set(string id, RateLimitCounter counter, TimeSpan expirationTime);
}
-}
+}
diff --git a/src/Ocelot/RateLimit/MemoryCacheRateLimitCounterHandler.cs b/src/Ocelot/RateLimit/MemoryCacheRateLimitCounterHandler.cs
index fdeeef66..f71766c8 100644
--- a/src/Ocelot/RateLimit/MemoryCacheRateLimitCounterHandler.cs
+++ b/src/Ocelot/RateLimit/MemoryCacheRateLimitCounterHandler.cs
@@ -1,8 +1,5 @@
using Microsoft.Extensions.Caching.Memory;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
@@ -42,4 +39,4 @@ namespace Ocelot.RateLimit
_memoryCache.Remove(id);
}
}
-}
+}
diff --git a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs
index 4647644e..5437ca11 100644
--- a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs
+++ b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs
@@ -1,13 +1,9 @@
-using Ocelot.Middleware;
-using System;
-using System.Collections.Generic;
+using Microsoft.AspNetCore.Http;
+using Ocelot.Configuration;
+using Ocelot.Logging;
+using Ocelot.Middleware;
using System.Linq;
using System.Threading.Tasks;
-using Ocelot.Infrastructure.RequestData;
-using Microsoft.AspNetCore.Http;
-using Ocelot.Logging;
-using Ocelot.Configuration;
-using Ocelot.DownstreamRouteFinder.Middleware;
namespace Ocelot.RateLimit.Middleware
{
@@ -20,7 +16,7 @@ namespace Ocelot.RateLimit.Middleware
public ClientRateLimitMiddleware(OcelotRequestDelegate next,
IOcelotLoggerFactory loggerFactory,
IRateLimitCounterHandler counterHandler)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_counterHandler = counterHandler;
@@ -29,9 +25,9 @@ namespace Ocelot.RateLimit.Middleware
public async Task Invoke(DownstreamContext context)
{
- var options = context.DownstreamReRoute.RateLimitOptions;
-
- // check if rate limiting is enabled
+ var options = context.DownstreamReRoute.RateLimitOptions;
+
+ // check if rate limiting is enabled
if (!context.DownstreamReRoute.EnableEndpointEndpointRateLimiting)
{
Logger.LogInformation($"EndpointRateLimiting is not enabled for {context.DownstreamReRoute.DownstreamPathTemplate.Value}");
@@ -65,12 +61,12 @@ namespace Ocelot.RateLimit.Middleware
// log blocked request
LogBlockedRequest(context.HttpContext, identity, counter, rule, context.DownstreamReRoute);
- var retrystring = retryAfter.ToString(System.Globalization.CultureInfo.InvariantCulture);
-
- // break execution
- await ReturnQuotaExceededResponse(context.HttpContext, options, retrystring);
-
- // Set Error
+ var retrystring = retryAfter.ToString(System.Globalization.CultureInfo.InvariantCulture);
+
+ // break execution
+ await ReturnQuotaExceededResponse(context.HttpContext, options, retrystring);
+
+ // Set Error
context.Errors.Add(new QuotaExceededError(this.GetResponseMessage(options)));
return;
@@ -116,8 +112,8 @@ namespace Ocelot.RateLimit.Middleware
{
Logger.LogInformation(
$"Request {identity.HttpVerb}:{identity.Path} from ClientId {identity.ClientId} has been blocked, quota {rule.Limit}/{rule.Period} exceeded by {counter.TotalRequests}. Blocked by rule { downstreamReRoute.UpstreamPathTemplate.OriginalValue }, TraceIdentifier {httpContext.TraceIdentifier}.");
- }
-
+ }
+
public virtual Task ReturnQuotaExceededResponse(HttpContext httpContext, RateLimitOptions option, string retryAfter)
{
var message = this.GetResponseMessage(option);
@@ -150,4 +146,4 @@ namespace Ocelot.RateLimit.Middleware
return Task.CompletedTask;
}
}
-}
+}
diff --git a/src/Ocelot/RateLimit/Middleware/RateLimitMiddlewareExtensions.cs b/src/Ocelot/RateLimit/Middleware/RateLimitMiddlewareExtensions.cs
index 2583be4a..3d686196 100644
--- a/src/Ocelot/RateLimit/Middleware/RateLimitMiddlewareExtensions.cs
+++ b/src/Ocelot/RateLimit/Middleware/RateLimitMiddlewareExtensions.cs
@@ -9,4 +9,4 @@ namespace Ocelot.RateLimit.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/RateLimit/RateLimitCore.cs b/src/Ocelot/RateLimit/RateLimitCore.cs
index 4b0d5165..e2e93e01 100644
--- a/src/Ocelot/RateLimit/RateLimitCore.cs
+++ b/src/Ocelot/RateLimit/RateLimitCore.cs
@@ -1,12 +1,9 @@
using Microsoft.AspNetCore.Http;
using Ocelot.Configuration;
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Security.Cryptography;
using System.Text;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
@@ -38,7 +35,7 @@ namespace Ocelot.RateLimit
{
// increment request count
var totalRequests = entry.Value.TotalRequests + 1;
-
+
// deep copy
counter = new RateLimitCounter(entry.Value.Timestamp, totalRequests);
}
@@ -71,7 +68,7 @@ namespace Ocelot.RateLimit
{
var counterId = ComputeCounterKey(requestIdentity, option);
var rule = option.RateLimitRule;
-
+
// stores: id (string) - timestamp (datetime) - total_requests (long)
_counterHandler.Set(counterId, counter, expirationTime);
}
@@ -134,15 +131,19 @@ namespace Ocelot.RateLimit
{
case "d":
return TimeSpan.FromDays(double.Parse(value));
+
case "h":
return TimeSpan.FromHours(double.Parse(value));
+
case "m":
return TimeSpan.FromMinutes(double.Parse(value));
+
case "s":
return TimeSpan.FromSeconds(double.Parse(value));
+
default:
throw new FormatException($"{timeSpan} can't be converted to TimeSpan, unknown type {type}");
}
- }
+ }
}
}
diff --git a/src/Ocelot/RateLimit/RateLimitCounter.cs b/src/Ocelot/RateLimit/RateLimitCounter.cs
index 46462d04..ac355e39 100644
--- a/src/Ocelot/RateLimit/RateLimitCounter.cs
+++ b/src/Ocelot/RateLimit/RateLimitCounter.cs
@@ -1,8 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
+using System;
namespace Ocelot.RateLimit
{
@@ -22,4 +19,4 @@ namespace Ocelot.RateLimit
public long TotalRequests { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/RateLimit/RateLimitHeaders.cs b/src/Ocelot/RateLimit/RateLimitHeaders.cs
index 5849fa75..b93cf04d 100644
--- a/src/Ocelot/RateLimit/RateLimitHeaders.cs
+++ b/src/Ocelot/RateLimit/RateLimitHeaders.cs
@@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Http;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace Ocelot.RateLimit
{
@@ -24,4 +20,4 @@ namespace Ocelot.RateLimit
public string Reset { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Request/Creator/DownstreamRequestCreator.cs b/src/Ocelot/Request/Creator/DownstreamRequestCreator.cs
index 352e70f3..560b6735 100644
--- a/src/Ocelot/Request/Creator/DownstreamRequestCreator.cs
+++ b/src/Ocelot/Request/Creator/DownstreamRequestCreator.cs
@@ -1,8 +1,8 @@
namespace Ocelot.Request.Creator
{
- using System.Net.Http;
- using Ocelot.Request.Middleware;
using Ocelot.Infrastructure;
+ using Ocelot.Request.Middleware;
+ using System.Net.Http;
public class DownstreamRequestCreator : IDownstreamRequestCreator
{
@@ -16,14 +16,14 @@ namespace Ocelot.Request.Creator
public DownstreamRequest Create(HttpRequestMessage request)
{
- /**
+ /**
* According to https://tools.ietf.org/html/rfc7231
* GET,HEAD,DELETE,CONNECT,TRACE
* Can have body but server can reject the request.
* And MS HttpClient in Full Framework actually rejects it.
- * see #366 issue
+ * see #366 issue
**/
- if(_framework.Get().Contains(DotNetFramework))
+ if (_framework.Get().Contains(DotNetFramework))
{
if (request.Method == HttpMethod.Get ||
request.Method == HttpMethod.Head ||
diff --git a/src/Ocelot/Request/Creator/IDownstreamRequestCreator.cs b/src/Ocelot/Request/Creator/IDownstreamRequestCreator.cs
index e6755399..dd87d5c8 100644
--- a/src/Ocelot/Request/Creator/IDownstreamRequestCreator.cs
+++ b/src/Ocelot/Request/Creator/IDownstreamRequestCreator.cs
@@ -1,7 +1,7 @@
namespace Ocelot.Request.Creator
{
- using System.Net.Http;
using Ocelot.Request.Middleware;
+ using System.Net.Http;
public interface IDownstreamRequestCreator
{
diff --git a/src/Ocelot/Request/Mapper/IRequestMapper.cs b/src/Ocelot/Request/Mapper/IRequestMapper.cs
index 941a24f7..d16a2d06 100644
--- a/src/Ocelot/Request/Mapper/IRequestMapper.cs
+++ b/src/Ocelot/Request/Mapper/IRequestMapper.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Request.Mapper
{
- using System.Net.Http;
- using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Ocelot.Responses;
+ using System.Net.Http;
+ using System.Threading.Tasks;
public interface IRequestMapper
{
diff --git a/src/Ocelot/Request/Mapper/RequestMapper.cs b/src/Ocelot/Request/Mapper/RequestMapper.cs
index d0c45807..f669c286 100644
--- a/src/Ocelot/Request/Mapper/RequestMapper.cs
+++ b/src/Ocelot/Request/Mapper/RequestMapper.cs
@@ -1,15 +1,15 @@
namespace Ocelot.Request.Mapper
{
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.AspNetCore.Http.Extensions;
+ using Microsoft.Extensions.Primitives;
+ using Ocelot.Responses;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Http.Extensions;
- using Microsoft.Extensions.Primitives;
- using Ocelot.Responses;
public class RequestMapper : IRequestMapper
{
@@ -38,7 +38,7 @@
private async Task MapContent(HttpRequest request)
{
- if (request.Body == null || (request.Body.CanSeek && request.Body.Length <= 0))
+ if (request.Body == null || (request.Body.CanSeek && request.Body.Length <= 0))
{
return null;
}
@@ -46,10 +46,10 @@
// Never change this to StreamContent again, I forgot it doesnt work in #464.
var content = new ByteArrayContent(await ToByteArray(request.Body));
- if(!string.IsNullOrEmpty(request.ContentType))
+ if (!string.IsNullOrEmpty(request.ContentType))
{
content.Headers
- .TryAddWithoutValidation("Content-Type", new[] {request.ContentType});
+ .TryAddWithoutValidation("Content-Type", new[] { request.ContentType });
}
AddHeaderIfExistsOnRequest("Content-Language", content, request);
@@ -58,17 +58,17 @@
AddHeaderIfExistsOnRequest("Content-MD5", content, request);
AddHeaderIfExistsOnRequest("Content-Disposition", content, request);
AddHeaderIfExistsOnRequest("Content-Encoding", content, request);
-
+
return content;
}
private void AddHeaderIfExistsOnRequest(string key, HttpContent content, HttpRequest request)
{
- if(request.Headers.ContainsKey(key))
+ if (request.Headers.ContainsKey(key))
{
content.Headers
- .TryAddWithoutValidation(key, request.Headers[key].ToList());
- }
+ .TryAddWithoutValidation(key, request.Headers[key].ToList());
+ }
}
private HttpMethod MapMethod(HttpRequest request)
@@ -99,7 +99,7 @@
private async Task ToByteArray(Stream stream)
{
- using(stream)
+ using (stream)
{
using (var memStream = new MemoryStream())
{
diff --git a/src/Ocelot/Request/Mapper/UnmappableRequestError.cs b/src/Ocelot/Request/Mapper/UnmappableRequestError.cs
index 81668eef..fa5a602a 100644
--- a/src/Ocelot/Request/Mapper/UnmappableRequestError.cs
+++ b/src/Ocelot/Request/Mapper/UnmappableRequestError.cs
@@ -9,4 +9,4 @@
{
}
}
-}
+}
diff --git a/src/Ocelot/Request/Middleware/DownstreamRequest.cs b/src/Ocelot/Request/Middleware/DownstreamRequest.cs
index 49d27efe..256436e5 100644
--- a/src/Ocelot/Request/Middleware/DownstreamRequest.cs
+++ b/src/Ocelot/Request/Middleware/DownstreamRequest.cs
@@ -69,7 +69,7 @@ namespace Ocelot.Request.Middleware
return uriBuilder.Uri.AbsoluteUri;
}
- public override string ToString()
+ public override string ToString()
{
return ToUri();
}
diff --git a/src/Ocelot/Request/Middleware/DownstreamRequestInitialiserMiddleware.cs b/src/Ocelot/Request/Middleware/DownstreamRequestInitialiserMiddleware.cs
index 4f3151d9..442bb4b9 100644
--- a/src/Ocelot/Request/Middleware/DownstreamRequestInitialiserMiddleware.cs
+++ b/src/Ocelot/Request/Middleware/DownstreamRequestInitialiserMiddleware.cs
@@ -1,12 +1,9 @@
namespace Ocelot.Request.Middleware
{
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Http;
- using Ocelot.DownstreamRouteFinder.Middleware;
- using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Request.Creator;
+ using System.Threading.Tasks;
public class DownstreamRequestInitialiserMiddleware : OcelotMiddleware
{
@@ -18,7 +15,7 @@ namespace Ocelot.Request.Middleware
IOcelotLoggerFactory loggerFactory,
Mapper.IRequestMapper requestMapper,
IDownstreamRequestCreator creator)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_requestMapper = requestMapper;
diff --git a/src/Ocelot/Request/Middleware/HttpRequestBuilderMiddlewareExtensions.cs b/src/Ocelot/Request/Middleware/HttpRequestBuilderMiddlewareExtensions.cs
index 35084659..2d803e1e 100644
--- a/src/Ocelot/Request/Middleware/HttpRequestBuilderMiddlewareExtensions.cs
+++ b/src/Ocelot/Request/Middleware/HttpRequestBuilderMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Request.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/RequestId/DefaultRequestIdKey.cs b/src/Ocelot/RequestId/DefaultRequestIdKey.cs
index 39f4b6ab..1dbd2e91 100644
--- a/src/Ocelot/RequestId/DefaultRequestIdKey.cs
+++ b/src/Ocelot/RequestId/DefaultRequestIdKey.cs
@@ -2,8 +2,8 @@
{
public static class DefaultRequestIdKey
{
- // This is set incase anyone isnt doing this specifically with there requests.
+ // This is set incase anyone isnt doing this specifically with there requests.
// It will not be forwarded on to downstream services unless specfied in the config.
public const string Value = "RequestId";
}
-}
+}
diff --git a/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs b/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs
index b9ddf824..4c802a02 100644
--- a/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs
+++ b/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs
@@ -1,12 +1,11 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Logging;
using Ocelot.Middleware;
-using System.Net.Http.Headers;
-using System.Collections.Generic;
using Ocelot.Request.Middleware;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
namespace Ocelot.RequestId.Middleware
{
@@ -16,7 +15,7 @@ namespace Ocelot.RequestId.Middleware
private readonly IRequestScopedDataRepository _requestScopedDataRepository;
public ReRouteRequestIdMiddleware(OcelotRequestDelegate next,
- IOcelotLoggerFactory loggerFactory,
+ IOcelotLoggerFactory loggerFactory,
IRequestScopedDataRepository requestScopedDataRepository)
: base(loggerFactory.CreateLogger())
{
@@ -76,4 +75,4 @@ namespace Ocelot.RequestId.Middleware
httpRequestMessage.Headers.Add(requestId.RequestIdKey, requestId.RequestIdValue);
}
}
-}
+}
diff --git a/src/Ocelot/RequestId/Middleware/RequestIdMiddlewareExtensions.cs b/src/Ocelot/RequestId/Middleware/RequestIdMiddlewareExtensions.cs
index f450f9a5..ce4e892d 100644
--- a/src/Ocelot/RequestId/Middleware/RequestIdMiddlewareExtensions.cs
+++ b/src/Ocelot/RequestId/Middleware/RequestIdMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.RequestId.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/RequestId/RequestId.cs b/src/Ocelot/RequestId/RequestId.cs
index 85f9cbbc..5d24088e 100644
--- a/src/Ocelot/RequestId/RequestId.cs
+++ b/src/Ocelot/RequestId/RequestId.cs
@@ -11,4 +11,4 @@
public string RequestIdKey { get; private set; }
public string RequestIdValue { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Requester/DelegatingHandlerHandlerFactory.cs b/src/Ocelot/Requester/DelegatingHandlerHandlerFactory.cs
index 45858787..3e868b32 100644
--- a/src/Ocelot/Requester/DelegatingHandlerHandlerFactory.cs
+++ b/src/Ocelot/Requester/DelegatingHandlerHandlerFactory.cs
@@ -1,14 +1,14 @@
namespace Ocelot.Requester
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
using Logging;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.Responses;
using QoS;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net.Http;
public class DelegatingHandlerHandlerFactory : IDelegatingHandlerHandlerFactory
{
diff --git a/src/Ocelot/Requester/HttpClientBuilder.cs b/src/Ocelot/Requester/HttpClientBuilder.cs
index 6194a33f..64df44b1 100644
--- a/src/Ocelot/Requester/HttpClientBuilder.cs
+++ b/src/Ocelot/Requester/HttpClientBuilder.cs
@@ -1,10 +1,10 @@
-using System;
+using Ocelot.Configuration;
+using Ocelot.Logging;
+using Ocelot.Middleware;
+using System;
using System.Linq;
using System.Net;
using System.Net.Http;
-using Ocelot.Configuration;
-using Ocelot.Logging;
-using Ocelot.Middleware;
namespace Ocelot.Requester
{
@@ -19,8 +19,8 @@ namespace Ocelot.Requester
private readonly TimeSpan _defaultTimeout;
public HttpClientBuilder(
- IDelegatingHandlerHandlerFactory factory,
- IHttpClientCache cacheHandlers,
+ IDelegatingHandlerHandlerFactory factory,
+ IHttpClientCache cacheHandlers,
IOcelotLogger logger)
{
_factory = factory;
@@ -55,7 +55,7 @@ namespace Ocelot.Requester
}
var timeout = context.DownstreamReRoute.QosOptions.TimeoutValue == 0
- ? _defaultTimeout
+ ? _defaultTimeout
: TimeSpan.FromMilliseconds(context.DownstreamReRoute.QosOptions.TimeoutValue);
_httpClient = new HttpClient(CreateHttpMessageHandler(handler, context.DownstreamReRoute))
@@ -73,7 +73,7 @@ namespace Ocelot.Requester
// Dont' create the CookieContainer if UseCookies is not set or the HttpClient will complain
// under .Net Full Framework
bool useCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer;
-
+
if (useCookies)
{
return UseCookiesHandler(context);
@@ -97,12 +97,12 @@ namespace Ocelot.Requester
private HttpClientHandler UseCookiesHandler(DownstreamContext context)
{
return new HttpClientHandler
- {
- AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
- UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
- UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
- CookieContainer = new CookieContainer()
- };
+ {
+ AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
+ UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
+ UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
+ CookieContainer = new CookieContainer()
+ };
}
public void Save()
diff --git a/src/Ocelot/Requester/HttpClientHttpRequester.cs b/src/Ocelot/Requester/HttpClientHttpRequester.cs
index 0705e7d2..eecf37db 100644
--- a/src/Ocelot/Requester/HttpClientHttpRequester.cs
+++ b/src/Ocelot/Requester/HttpClientHttpRequester.cs
@@ -1,9 +1,9 @@
-using System;
-using System.Net.Http;
-using System.Threading.Tasks;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Responses;
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
namespace Ocelot.Requester
{
@@ -16,7 +16,7 @@ namespace Ocelot.Requester
public HttpClientHttpRequester(IOcelotLoggerFactory loggerFactory,
IHttpClientCache cacheHandlers,
- IDelegatingHandlerHandlerFactory factory,
+ IDelegatingHandlerHandlerFactory factory,
IExceptionToErrorMapper mapper)
{
_logger = loggerFactory.CreateLogger();
@@ -33,7 +33,7 @@ namespace Ocelot.Requester
try
{
- var response = await httpClient.SendAsync(context.DownstreamRequest.ToHttpRequestMessage());
+ var response = await httpClient.SendAsync(context.DownstreamRequest.ToHttpRequestMessage(), context.HttpContext.RequestAborted);
return new OkResponse(response);
}
catch (Exception exception)
diff --git a/src/Ocelot/Requester/HttpClientWrapper.cs b/src/Ocelot/Requester/HttpClientWrapper.cs
index b1f0345a..3f20bb37 100644
--- a/src/Ocelot/Requester/HttpClientWrapper.cs
+++ b/src/Ocelot/Requester/HttpClientWrapper.cs
@@ -1,4 +1,5 @@
using System.Net.Http;
+using System.Threading;
using System.Threading.Tasks;
namespace Ocelot.Requester
@@ -15,9 +16,9 @@ namespace Ocelot.Requester
Client = client;
}
- public Task SendAsync(HttpRequestMessage request)
+ public Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
{
- return Client.SendAsync(request);
+ return Client.SendAsync(request, cancellationToken);
}
}
}
diff --git a/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs b/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
index 27e9c4ba..100d01f4 100644
--- a/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
+++ b/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Requester
{
- using System;
- using System.Collections.Generic;
using Errors;
using Microsoft.Extensions.DependencyInjection;
+ using System;
+ using System.Collections.Generic;
public class HttpExeptionToErrorMapper : IExceptionToErrorMapper
{
@@ -23,6 +23,11 @@ namespace Ocelot.Requester
return _mappers[type](exception);
}
+ if (type == typeof(OperationCanceledException))
+ {
+ return new RequestCanceledError(exception.Message);
+ }
+
return new UnableToCompleteRequestError(exception);
}
}
diff --git a/src/Ocelot/Requester/IDelegatingHandlerHandlerFactory.cs b/src/Ocelot/Requester/IDelegatingHandlerHandlerFactory.cs
index 4d905c35..cf0b6d07 100644
--- a/src/Ocelot/Requester/IDelegatingHandlerHandlerFactory.cs
+++ b/src/Ocelot/Requester/IDelegatingHandlerHandlerFactory.cs
@@ -1,10 +1,10 @@
namespace Ocelot.Requester
{
+ using Ocelot.Configuration;
+ using Ocelot.Responses;
using System;
using System.Collections.Generic;
using System.Net.Http;
- using Ocelot.Configuration;
- using Ocelot.Responses;
public interface IDelegatingHandlerHandlerFactory
{
diff --git a/src/Ocelot/Requester/IExceptionToErrorMapper.cs b/src/Ocelot/Requester/IExceptionToErrorMapper.cs
index 9d765fa7..dd23f10b 100644
--- a/src/Ocelot/Requester/IExceptionToErrorMapper.cs
+++ b/src/Ocelot/Requester/IExceptionToErrorMapper.cs
@@ -1,5 +1,5 @@
-using System;
-using Ocelot.Errors;
+using Ocelot.Errors;
+using System;
namespace Ocelot.Requester
{
diff --git a/src/Ocelot/Requester/IHttpClient.cs b/src/Ocelot/Requester/IHttpClient.cs
index 1912ab0b..9cca2198 100644
--- a/src/Ocelot/Requester/IHttpClient.cs
+++ b/src/Ocelot/Requester/IHttpClient.cs
@@ -1,5 +1,5 @@
-using System;
-using System.Net.Http;
+using System.Net.Http;
+using System.Threading;
using System.Threading.Tasks;
namespace Ocelot.Requester
@@ -8,6 +8,6 @@ namespace Ocelot.Requester
{
HttpClient Client { get; }
- Task SendAsync(HttpRequestMessage request);
+ Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default);
}
-}
+}
diff --git a/src/Ocelot/Requester/IHttpClientBuilder.cs b/src/Ocelot/Requester/IHttpClientBuilder.cs
index cc8c6160..40bb2949 100644
--- a/src/Ocelot/Requester/IHttpClientBuilder.cs
+++ b/src/Ocelot/Requester/IHttpClientBuilder.cs
@@ -5,6 +5,7 @@ namespace Ocelot.Requester
public interface IHttpClientBuilder
{
IHttpClient Create(DownstreamContext request);
+
void Save();
}
}
diff --git a/src/Ocelot/Requester/IHttpClientCache.cs b/src/Ocelot/Requester/IHttpClientCache.cs
index c9e90f04..ac4cd2fd 100644
--- a/src/Ocelot/Requester/IHttpClientCache.cs
+++ b/src/Ocelot/Requester/IHttpClientCache.cs
@@ -1,11 +1,12 @@
namespace Ocelot.Requester
{
- using System;
using Configuration;
+ using System;
public interface IHttpClientCache
{
IHttpClient Get(DownstreamReRoute key);
+
void Set(DownstreamReRoute key, IHttpClient handler, TimeSpan expirationTime);
}
-}
+}
diff --git a/src/Ocelot/Requester/IHttpRequester.cs b/src/Ocelot/Requester/IHttpRequester.cs
index 86f6209a..18f5ed78 100644
--- a/src/Ocelot/Requester/IHttpRequester.cs
+++ b/src/Ocelot/Requester/IHttpRequester.cs
@@ -1,7 +1,7 @@
-using System.Net.Http;
-using System.Threading.Tasks;
-using Ocelot.Middleware;
+using Ocelot.Middleware;
using Ocelot.Responses;
+using System.Net.Http;
+using System.Threading.Tasks;
namespace Ocelot.Requester
{
@@ -9,4 +9,4 @@ namespace Ocelot.Requester
{
Task> GetResponse(DownstreamContext context);
}
-}
+}
diff --git a/src/Ocelot/Requester/MemoryHttpClientCache.cs b/src/Ocelot/Requester/MemoryHttpClientCache.cs
index b2fcc2a0..433d4ac6 100644
--- a/src/Ocelot/Requester/MemoryHttpClientCache.cs
+++ b/src/Ocelot/Requester/MemoryHttpClientCache.cs
@@ -1,8 +1,8 @@
namespace Ocelot.Requester
{
+ using Configuration;
using System;
using System.Collections.Concurrent;
- using Configuration;
public class MemoryHttpClientCache : IHttpClientCache
{
@@ -22,6 +22,6 @@
{
//todo handle error?
return _httpClientsCache.TryGetValue(key, out var client) ? client : null;
- }
+ }
}
}
diff --git a/src/Ocelot/Requester/Middleware/HttpRequesterMiddlewareExtensions.cs b/src/Ocelot/Requester/Middleware/HttpRequesterMiddlewareExtensions.cs
index 82013d4c..d92f7909 100644
--- a/src/Ocelot/Requester/Middleware/HttpRequesterMiddlewareExtensions.cs
+++ b/src/Ocelot/Requester/Middleware/HttpRequesterMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Requester.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs
index 0ad4d410..0bf56922 100644
--- a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs
+++ b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs
@@ -1,11 +1,11 @@
namespace Ocelot.Requester
{
using Logging;
+ using Ocelot.Infrastructure.RequestData;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
- using Ocelot.Infrastructure.RequestData;
public class OcelotHttpTracingHandler : DelegatingHandler, ITracingHandler
{
diff --git a/src/Ocelot/Requester/QoS/IQosFactory.cs b/src/Ocelot/Requester/QoS/IQosFactory.cs
index fb795504..5a3477cb 100644
--- a/src/Ocelot/Requester/QoS/IQosFactory.cs
+++ b/src/Ocelot/Requester/QoS/IQosFactory.cs
@@ -1,8 +1,8 @@
namespace Ocelot.Requester.QoS
{
- using System.Net.Http;
using Configuration;
using Responses;
+ using System.Net.Http;
public interface IQoSFactory
{
diff --git a/src/Ocelot/Requester/QoS/QosFactory.cs b/src/Ocelot/Requester/QoS/QosFactory.cs
index 37211f4b..711bc2c7 100644
--- a/src/Ocelot/Requester/QoS/QosFactory.cs
+++ b/src/Ocelot/Requester/QoS/QosFactory.cs
@@ -1,11 +1,11 @@
namespace Ocelot.Requester.QoS
{
- using System;
- using System.Net.Http;
using Configuration;
using Logging;
using Microsoft.Extensions.DependencyInjection;
using Responses;
+ using System;
+ using System.Net.Http;
public class QoSFactory : IQoSFactory
{
diff --git a/src/Ocelot/Requester/QoS/UnableToFindQoSProviderError.cs b/src/Ocelot/Requester/QoS/UnableToFindQoSProviderError.cs
index e3c02b27..de0882ac 100644
--- a/src/Ocelot/Requester/QoS/UnableToFindQoSProviderError.cs
+++ b/src/Ocelot/Requester/QoS/UnableToFindQoSProviderError.cs
@@ -4,9 +4,9 @@
public class UnableToFindQoSProviderError : Error
{
- public UnableToFindQoSProviderError(string message)
+ public UnableToFindQoSProviderError(string message)
: base(message, OcelotErrorCode.UnableToFindQoSProviderError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Requester/QosDelegatingHandlerDelegate.cs b/src/Ocelot/Requester/QosDelegatingHandlerDelegate.cs
index a0c66955..7b76c4c9 100644
--- a/src/Ocelot/Requester/QosDelegatingHandlerDelegate.cs
+++ b/src/Ocelot/Requester/QosDelegatingHandlerDelegate.cs
@@ -1,8 +1,8 @@
namespace Ocelot.Requester
{
- using System.Net.Http;
using Configuration;
using Logging;
+ using System.Net.Http;
public delegate DelegatingHandler QosDelegatingHandlerDelegate(DownstreamReRoute reRoute, IOcelotLoggerFactory logger);
}
diff --git a/src/Ocelot/Requester/RequestCanceledError.cs b/src/Ocelot/Requester/RequestCanceledError.cs
new file mode 100644
index 00000000..1944fada
--- /dev/null
+++ b/src/Ocelot/Requester/RequestCanceledError.cs
@@ -0,0 +1,11 @@
+using Ocelot.Errors;
+
+namespace Ocelot.Requester
+{
+ public class RequestCanceledError : Error
+ {
+ public RequestCanceledError(string message) : base(message, OcelotErrorCode.RequestCanceled)
+ {
+ }
+ }
+}
diff --git a/src/Ocelot/Requester/TracingHandlerFactory.cs b/src/Ocelot/Requester/TracingHandlerFactory.cs
index 2740ef96..afb26845 100644
--- a/src/Ocelot/Requester/TracingHandlerFactory.cs
+++ b/src/Ocelot/Requester/TracingHandlerFactory.cs
@@ -1,9 +1,9 @@
namespace Ocelot.Requester
{
- using System;
using Logging;
- using Ocelot.Infrastructure.RequestData;
using Microsoft.Extensions.DependencyInjection;
+ using Ocelot.Infrastructure.RequestData;
+ using System;
public class TracingHandlerFactory : ITracingHandlerFactory
{
diff --git a/src/Ocelot/Requester/UnableToCompleteRequestError.cs b/src/Ocelot/Requester/UnableToCompleteRequestError.cs
index c5eb7b31..26302039 100644
--- a/src/Ocelot/Requester/UnableToCompleteRequestError.cs
+++ b/src/Ocelot/Requester/UnableToCompleteRequestError.cs
@@ -1,13 +1,13 @@
-using System;
-using Ocelot.Errors;
+using Ocelot.Errors;
+using System;
namespace Ocelot.Requester
{
public class UnableToCompleteRequestError : Error
{
- public UnableToCompleteRequestError(Exception exception)
+ public UnableToCompleteRequestError(Exception exception)
: base($"Error making http request, exception: {exception}", OcelotErrorCode.UnableToCompleteRequestError)
{
}
}
-}
+}
diff --git a/src/Ocelot/Responder/ErrorsToHttpStatusCodeMapper.cs b/src/Ocelot/Responder/ErrorsToHttpStatusCodeMapper.cs
index a417f2f9..c50daa27 100644
--- a/src/Ocelot/Responder/ErrorsToHttpStatusCodeMapper.cs
+++ b/src/Ocelot/Responder/ErrorsToHttpStatusCodeMapper.cs
@@ -1,6 +1,6 @@
+using Ocelot.Errors;
using System.Collections.Generic;
using System.Linq;
-using Ocelot.Errors;
namespace Ocelot.Responder
{
@@ -13,7 +13,7 @@ namespace Ocelot.Responder
return 401;
}
- if (errors.Any(e => e.Code == OcelotErrorCode.UnauthorizedError
+ if (errors.Any(e => e.Code == OcelotErrorCode.UnauthorizedError
|| e.Code == OcelotErrorCode.ClaimValueNotAuthorisedError
|| e.Code == OcelotErrorCode.ScopeNotAuthorisedError
|| e.Code == OcelotErrorCode.UserDoesNotHaveClaimError
@@ -27,6 +27,14 @@ namespace Ocelot.Responder
return 503;
}
+ if (errors.Any(e => e.Code == OcelotErrorCode.RequestCanceled))
+ {
+ // status code refer to
+ // https://stackoverflow.com/questions/46234679/what-is-the-correct-http-status-code-for-a-cancelled-request?answertab=votes#tab-top
+ // https://httpstatuses.com/499
+ return 499;
+ }
+
if (errors.Any(e => e.Code == OcelotErrorCode.UnableToFindDownstreamRouteError))
{
return 404;
@@ -40,4 +48,4 @@ namespace Ocelot.Responder
return 404;
}
}
-}
+}
diff --git a/src/Ocelot/Responder/HttpContextResponder.cs b/src/Ocelot/Responder/HttpContextResponder.cs
index ebb09ab2..509df689 100644
--- a/src/Ocelot/Responder/HttpContextResponder.cs
+++ b/src/Ocelot/Responder/HttpContextResponder.cs
@@ -1,12 +1,11 @@
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
using Ocelot.Headers;
using Ocelot.Middleware;
+using System.Linq;
+using System.Net;
+using System.Threading.Tasks;
namespace Ocelot.Responder
{
@@ -48,12 +47,12 @@ namespace Ocelot.Responder
var content = await response.Content.ReadAsStreamAsync();
- if(response.Content.Headers.ContentLength != null)
+ if (response.Content.Headers.ContentLength != null)
{
- AddHeaderIfDoesntExist(context, new Header("Content-Length", new []{ response.Content.Headers.ContentLength.ToString() }) );
+ AddHeaderIfDoesntExist(context, new Header("Content-Length", new[] { response.Content.Headers.ContentLength.ToString() }));
}
- using(content)
+ using (content)
{
if (response.StatusCode != HttpStatusCode.NotModified && context.Response.ContentLength != 0)
{
diff --git a/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs b/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
index 61330db9..26da864f 100644
--- a/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
+++ b/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
-using Ocelot.Errors;
+using Ocelot.Errors;
+using System.Collections.Generic;
namespace Ocelot.Responder
{
diff --git a/src/Ocelot/Responder/IHttpResponder.cs b/src/Ocelot/Responder/IHttpResponder.cs
index 73722f53..5a32950a 100644
--- a/src/Ocelot/Responder/IHttpResponder.cs
+++ b/src/Ocelot/Responder/IHttpResponder.cs
@@ -1,13 +1,13 @@
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Ocelot.Middleware;
-using Ocelot.Middleware.Multiplexer;
+using System.Threading.Tasks;
namespace Ocelot.Responder
{
public interface IHttpResponder
{
Task SetResponseOnHttpContext(HttpContext context, DownstreamResponse response);
+
void SetErrorResponseOnContext(HttpContext context, int statusCode);
}
-}
+}
diff --git a/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs b/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs
index ec6696c5..43f01acb 100644
--- a/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs
+++ b/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Http;
using Ocelot.Errors;
+using Ocelot.Infrastructure.Extensions;
using Ocelot.Logging;
using Ocelot.Middleware;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Ocelot.Infrastructure.Extensions;
namespace Ocelot.Responder.Middleware
{
@@ -17,12 +17,12 @@ namespace Ocelot.Responder.Middleware
private readonly IHttpResponder _responder;
private readonly IErrorsToHttpStatusCodeMapper _codeMapper;
- public ResponderMiddleware(OcelotRequestDelegate next,
+ public ResponderMiddleware(OcelotRequestDelegate next,
IHttpResponder responder,
IOcelotLoggerFactory loggerFactory,
IErrorsToHttpStatusCodeMapper codeMapper
)
- :base(loggerFactory.CreateLogger())
+ : base(loggerFactory.CreateLogger())
{
_next = next;
_responder = responder;
@@ -30,13 +30,13 @@ namespace Ocelot.Responder.Middleware
}
public async Task Invoke(DownstreamContext context)
- {
+ {
await _next.Invoke(context);
if (context.IsError)
{
Logger.LogWarning($"{context.Errors.ToErrorString()} errors found in {MiddlewareName}. Setting error response for request path:{context.HttpContext.Request.Path}, request method: {context.HttpContext.Request.Method}");
-
+
SetErrorResponse(context.HttpContext, context.Errors);
}
else
diff --git a/src/Ocelot/Responder/Middleware/ResponderMiddlewareExtensions.cs b/src/Ocelot/Responder/Middleware/ResponderMiddlewareExtensions.cs
index 9379708f..9e890412 100644
--- a/src/Ocelot/Responder/Middleware/ResponderMiddlewareExtensions.cs
+++ b/src/Ocelot/Responder/Middleware/ResponderMiddlewareExtensions.cs
@@ -10,4 +10,4 @@ namespace Ocelot.Responder.Middleware
return builder.UseMiddleware();
}
}
-}
+}
diff --git a/src/Ocelot/Responses/ErrorResponse.cs b/src/Ocelot/Responses/ErrorResponse.cs
index 156243ab..56a3eb23 100644
--- a/src/Ocelot/Responses/ErrorResponse.cs
+++ b/src/Ocelot/Responses/ErrorResponse.cs
@@ -1,18 +1,18 @@
-using System.Collections.Generic;
using Ocelot.Errors;
+using System.Collections.Generic;
namespace Ocelot.Responses
{
public class ErrorResponse : Response
{
- public ErrorResponse(Error error)
- : base(new List{error})
+ public ErrorResponse(Error error)
+ : base(new List { error })
{
}
- public ErrorResponse(List errors)
+ public ErrorResponse(List errors)
: base(errors)
{
}
}
-}
+}
diff --git a/src/Ocelot/Responses/ErrorResponseGeneric.cs b/src/Ocelot/Responses/ErrorResponseGeneric.cs
index f57de97f..0dbf4272 100644
--- a/src/Ocelot/Responses/ErrorResponseGeneric.cs
+++ b/src/Ocelot/Responses/ErrorResponseGeneric.cs
@@ -1,20 +1,21 @@
-using System.Collections.Generic;
using Ocelot.Errors;
+using System.Collections.Generic;
namespace Ocelot.Responses
{
#pragma warning disable SA1649 // File name must match first type name
+
public class ErrorResponse : Response
#pragma warning restore SA1649 // File name must match first type name
{
- public ErrorResponse(Error error)
- : base(new List {error})
- {
+ public ErrorResponse(Error error)
+ : base(new List { error })
+ {
}
- public ErrorResponse(List errors)
+ public ErrorResponse(List errors)
: base(errors)
{
}
}
-}
+}
diff --git a/src/Ocelot/Responses/OkResponseGeneric.cs b/src/Ocelot/Responses/OkResponseGeneric.cs
index 73fcf1e2..cc0ccc12 100644
--- a/src/Ocelot/Responses/OkResponseGeneric.cs
+++ b/src/Ocelot/Responses/OkResponseGeneric.cs
@@ -1,6 +1,7 @@
namespace Ocelot.Responses
{
#pragma warning disable SA1649 // File name must match first type name
+
public class OkResponse : Response
#pragma warning restore SA1649 // File name must match first type name
{
@@ -8,4 +9,4 @@ namespace Ocelot.Responses
{
}
}
-}
+}
diff --git a/src/Ocelot/Responses/Response.cs b/src/Ocelot/Responses/Response.cs
index 3a387a2b..a10d480b 100644
--- a/src/Ocelot/Responses/Response.cs
+++ b/src/Ocelot/Responses/Response.cs
@@ -1,5 +1,5 @@
-using System.Collections.Generic;
using Ocelot.Errors;
+using System.Collections.Generic;
namespace Ocelot.Responses
{
@@ -13,10 +13,10 @@ namespace Ocelot.Responses
protected Response(List errors)
{
Errors = errors ?? new List();
- }
-
+ }
+
public List Errors { get; }
public bool IsError => Errors.Count > 0;
}
-}
+}
diff --git a/src/Ocelot/Responses/ResponseGeneric.cs b/src/Ocelot/Responses/ResponseGeneric.cs
index 0b2514e9..2deeb113 100644
--- a/src/Ocelot/Responses/ResponseGeneric.cs
+++ b/src/Ocelot/Responses/ResponseGeneric.cs
@@ -1,9 +1,10 @@
-using System.Collections.Generic;
using Ocelot.Errors;
+using System.Collections.Generic;
namespace Ocelot.Responses
{
#pragma warning disable SA1649 // File name must match first type name
+
public abstract class Response : Response
#pragma warning restore SA1649 // File name must match first type name
{
@@ -16,6 +17,6 @@ namespace Ocelot.Responses
{
}
- public T Data { get; private set; }
+ public T Data { get; private set; }
}
-}
+}
diff --git a/src/Ocelot/Security/IPSecurity/IPSecurityPolicy.cs b/src/Ocelot/Security/IPSecurity/IPSecurityPolicy.cs
index bbf97778..19c75e59 100644
--- a/src/Ocelot/Security/IPSecurity/IPSecurityPolicy.cs
+++ b/src/Ocelot/Security/IPSecurity/IPSecurityPolicy.cs
@@ -1,11 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Text;
-using System.Threading.Tasks;
-using Ocelot.Configuration;
+using Ocelot.Configuration;
using Ocelot.Middleware;
using Ocelot.Responses;
+using System.Net;
+using System.Threading.Tasks;
namespace Ocelot.Security.IPSecurity
{
@@ -37,7 +34,7 @@ namespace Ocelot.Security.IPSecurity
return new ErrorResponse(error);
}
}
-
+
return await Task.FromResult(new OkResponse());
}
}
diff --git a/src/Ocelot/Security/ISecurityPolicy.cs b/src/Ocelot/Security/ISecurityPolicy.cs
index 2b3457ec..c6854610 100644
--- a/src/Ocelot/Security/ISecurityPolicy.cs
+++ b/src/Ocelot/Security/ISecurityPolicy.cs
@@ -1,8 +1,5 @@
using Ocelot.Middleware;
using Ocelot.Responses;
-using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading.Tasks;
namespace Ocelot.Security
diff --git a/src/Ocelot/Security/Middleware/SecurityMiddleware.cs b/src/Ocelot/Security/Middleware/SecurityMiddleware.cs
index 1665ba3b..657445b8 100644
--- a/src/Ocelot/Security/Middleware/SecurityMiddleware.cs
+++ b/src/Ocelot/Security/Middleware/SecurityMiddleware.cs
@@ -10,6 +10,7 @@ namespace Ocelot.Security.Middleware
private readonly OcelotRequestDelegate _next;
private readonly IOcelotLogger _logger;
private readonly IEnumerable _securityPolicies;
+
public SecurityMiddleware(IOcelotLoggerFactory loggerFactory,
IEnumerable