diff --git a/samples/AdministrationApi/AdministrationApi.csproj b/samples/AdministrationApi/AdministrationApi.csproj
index 901c1f093..59739bdee 100644
--- a/samples/AdministrationApi/AdministrationApi.csproj
+++ b/samples/AdministrationApi/AdministrationApi.csproj
@@ -1,13 +1,13 @@
- net6.0
+ net7.0
-
-
+
+
diff --git a/samples/AdministrationApi/Issue645.postman_collection.json b/samples/AdministrationApi/Issue645.postman_collection.json
index 2cdd868ef..c9bac89f5 100644
--- a/samples/AdministrationApi/Issue645.postman_collection.json
+++ b/samples/AdministrationApi/Issue645.postman_collection.json
@@ -132,7 +132,7 @@
"id": "0f60e7b3-e4f1-4458-bbc4-fc4809e86b2d",
"type": "text/javascript",
"exec": [
- ""
+ string.Empty
]
}
},
@@ -142,7 +142,7 @@
"id": "1279a2cf-b771-4a86-9dfa-302b240fac62",
"type": "text/javascript",
"exec": [
- ""
+ string.Empty
]
}
}
diff --git a/samples/AdministrationApi/Program.cs b/samples/AdministrationApi/Program.cs
index a69f1dc61..36695bf9a 100644
--- a/samples/AdministrationApi/Program.cs
+++ b/samples/AdministrationApi/Program.cs
@@ -1,45 +1,48 @@
-using Microsoft.AspNetCore.Hosting;
+using System.IO;
+
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
+
using Ocelot.Administration;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
-using System.IO;
namespace AdministrationApi
{
public class Program
-{
- public static void Main(string[] args)
{
- new WebHostBuilder()
- .UseKestrel()
- .UseUrls("http://localhost:5000")
- .UseContentRoot(Directory.GetCurrentDirectory())
- .ConfigureAppConfiguration((hostingContext, config) =>
- {
- config
- .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
- .AddJsonFile("appsettings.json", true, true)
- .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
- .AddJsonFile("ocelot.json")
- .AddEnvironmentVariables();
- })
- .ConfigureServices(s => {
- s.AddOcelot()
- .AddAdministration("/administration", "secret");
- })
- .ConfigureLogging((hostingContext, logging) =>
- {
- logging.AddConsole();
- })
- .UseIISIntegration()
- .Configure(app =>
- {
- app.UseOcelot().Wait();
- })
- .Build()
- .Run();
+ public static void Main(string[] args)
+ {
+ new WebHostBuilder()
+ .UseKestrel()
+ .UseUrls("http://localhost:5000")
+ .UseContentRoot(Directory.GetCurrentDirectory())
+ .ConfigureAppConfiguration((hostingContext, config) =>
+ {
+ config
+ .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
+ .AddJsonFile("appsettings.json", true, true)
+ .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
+ .AddJsonFile("ocelot.json")
+ .AddEnvironmentVariables();
+ })
+ .ConfigureServices(s =>
+ {
+ s.AddOcelot()
+ .AddAdministration("/administration", "secret");
+ })
+ .ConfigureLogging((hostingContext, logging) =>
+ {
+ logging.AddConsole();
+ })
+ .UseIISIntegration()
+ .Configure(app =>
+ {
+ app.UseOcelot().Wait();
+ })
+ .Build()
+ .Run();
+ }
}
}
-}
diff --git a/samples/OcelotBasic/OcelotBasic.csproj b/samples/OcelotBasic/OcelotBasic.csproj
index 686a1b98b..10cdb7313 100644
--- a/samples/OcelotBasic/OcelotBasic.csproj
+++ b/samples/OcelotBasic/OcelotBasic.csproj
@@ -1,11 +1,11 @@
- net6.0
+ net7.0
-
+
diff --git a/samples/OcelotBasic/Program.cs b/samples/OcelotBasic/Program.cs
index c0d8bed6a..dfc77fc75 100644
--- a/samples/OcelotBasic/Program.cs
+++ b/samples/OcelotBasic/Program.cs
@@ -1,7 +1,7 @@
using System.IO;
+
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
@@ -23,7 +23,8 @@ public static void Main(string[] args)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
})
- .ConfigureServices(s => {
+ .ConfigureServices(s =>
+ {
s.AddOcelot();
})
.ConfigureLogging((hostingContext, logging) =>
diff --git a/samples/OcelotEureka/ApiGateway/ApiGateway.csproj b/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
index a9e7ba6fa..a286c8a16 100644
--- a/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
+++ b/samples/OcelotEureka/ApiGateway/ApiGateway.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
@@ -15,9 +15,9 @@
-
-
-
+
+
+
diff --git a/samples/OcelotEureka/ApiGateway/Program.cs b/samples/OcelotEureka/ApiGateway/Program.cs
index f2cd87f92..9a5b918d8 100644
--- a/samples/OcelotEureka/ApiGateway/Program.cs
+++ b/samples/OcelotEureka/ApiGateway/Program.cs
@@ -6,6 +6,7 @@ namespace ApiGateway
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
+
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
diff --git a/samples/OcelotEureka/DownstreamService/Controllers/CategoryController.cs b/samples/OcelotEureka/DownstreamService/Controllers/CategoryController.cs
index 53350be74..5ce38f475 100644
--- a/samples/OcelotEureka/DownstreamService/Controllers/CategoryController.cs
+++ b/samples/OcelotEureka/DownstreamService/Controllers/CategoryController.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+
using Microsoft.AspNetCore.Mvc;
namespace DownstreamService.Controllers
diff --git a/samples/OcelotEureka/DownstreamService/DownstreamService.csproj b/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
index 91405f715..748249c00 100644
--- a/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
+++ b/samples/OcelotEureka/DownstreamService/DownstreamService.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
diff --git a/samples/OcelotEureka/DownstreamService/Program.cs b/samples/OcelotEureka/DownstreamService/Program.cs
index ddce0c286..130b46f0e 100644
--- a/samples/OcelotEureka/DownstreamService/Program.cs
+++ b/samples/OcelotEureka/DownstreamService/Program.cs
@@ -1,4 +1,5 @@
using System;
+
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
diff --git a/samples/OcelotEureka/DownstreamService/Startup.cs b/samples/OcelotEureka/DownstreamService/Startup.cs
index aa488ad84..d7ec4d555 100644
--- a/samples/OcelotEureka/DownstreamService/Startup.cs
+++ b/samples/OcelotEureka/DownstreamService/Startup.cs
@@ -1,17 +1,12 @@
-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.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
namespace DownstreamService
{
using Microsoft.Extensions.Hosting;
+
using Steeltoe.Discovery.Client;
public class Startup
diff --git a/samples/OcelotGraphQL/OcelotGraphQL.csproj b/samples/OcelotGraphQL/OcelotGraphQL.csproj
index 455400227..06956a7f8 100644
--- a/samples/OcelotGraphQL/OcelotGraphQL.csproj
+++ b/samples/OcelotGraphQL/OcelotGraphQL.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
@@ -11,7 +11,7 @@
-
-
+
+
diff --git a/samples/OcelotGraphQL/Program.cs b/samples/OcelotGraphQL/Program.cs
index ef23d98d4..bbf5eff48 100644
--- a/samples/OcelotGraphQL/Program.cs
+++ b/samples/OcelotGraphQL/Program.cs
@@ -1,22 +1,21 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Threading;
using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+
+using GraphQL;
+using GraphQL.Types;
+
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Ocelot.Middleware;
+
using Ocelot.DependencyInjection;
-using GraphQL.Types;
-using GraphQL;
-using Ocelot.Requester;
-using Ocelot.Responses;
-using System.Net.Http;
-using System.Net;
-using Microsoft.Extensions.DependencyInjection;
-using System.Threading;
+using Ocelot.Middleware;
namespace OcelotGraphQL
{
@@ -28,7 +27,7 @@ public class Hero
public class Query
{
- private readonly List _heroes = new List
+ private readonly List _heroes = new()
{
new Hero { Id = 1, Name = "R2-D2" },
new Hero { Id = 2, Name = "Batman" },
@@ -45,35 +44,35 @@ public Hero GetHero(int id)
public class GraphQlDelegatingHandler : DelegatingHandler
{
- //private readonly ISchema _schema;
- private readonly IDocumentExecuter _executer;
+ //private readonly ISchema _schema;
+ private readonly IDocumentExecuter _executer;
private readonly IDocumentWriter _writer;
public GraphQlDelegatingHandler(IDocumentExecuter executer, IDocumentWriter writer)
{
- _executer = executer;
+ _executer = executer;
_writer = writer;
}
- protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
+ protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
//try get query from body, could check http method :)
- var query = await request.Content.ReadAsStringAsync();
+ var query = await request.Content.ReadAsStringAsync(cancellationToken);
//if not body try query string, dont hack like this in real world..
if (query.Length == 0)
{
var decoded = WebUtility.UrlDecode(request.RequestUri.Query);
- query = decoded.Replace("?query=", "");
+ query = decoded.Replace("?query=", string.Empty);
}
-
+
var result = await _executer.ExecuteAsync(_ =>
{
_.Query = query;
- });
-
+ });
+
var responseBody = await _writer.WriteToStringAsync(result);
-
+
//maybe check for errors and headers etc in real world?
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
diff --git a/samples/OcelotKube/ApiGateway/ApiGateway.csproj b/samples/OcelotKube/ApiGateway/ApiGateway.csproj
index 32ecc63ab..934916601 100644
--- a/samples/OcelotKube/ApiGateway/ApiGateway.csproj
+++ b/samples/OcelotKube/ApiGateway/ApiGateway.csproj
@@ -1,15 +1,15 @@
- net6.0
+ net7.0
InProcess
Linux
-
-
-
+
+
+
diff --git a/samples/OcelotKube/ApiGateway/Program.cs b/samples/OcelotKube/ApiGateway/Program.cs
index 978c8ccc9..ee852d8bf 100644
--- a/samples/OcelotKube/ApiGateway/Program.cs
+++ b/samples/OcelotKube/ApiGateway/Program.cs
@@ -1,9 +1,6 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
-using Ocelot.DependencyInjection;
-using Ocelot.Middleware;
-using Ocelot.Provider.Kubernetes;
namespace ApiGateway
{
diff --git a/samples/OcelotKube/ApiGateway/Startup.cs b/samples/OcelotKube/ApiGateway/Startup.cs
index 3e37ffa3c..f5746c99b 100644
--- a/samples/OcelotKube/ApiGateway/Startup.cs
+++ b/samples/OcelotKube/ApiGateway/Startup.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Kubernetes;
diff --git a/samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs b/samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs
index 425cf18de..753bf5dd6 100644
--- a/samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs
+++ b/samples/OcelotKube/DownstreamService/Controllers/ValuesController.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Collections.Generic;
+
using Microsoft.AspNetCore.Mvc;
namespace DownstreamService.Controllers
@@ -14,7 +12,7 @@ public class ValuesController : ControllerBase
[HttpGet]
public ActionResult> Get()
{
- return new string[] { "value1", "value2" };
+ return new[] { "value1", "value2" };
}
// GET api/values/5
diff --git a/samples/OcelotKube/DownstreamService/DownstreamService.csproj b/samples/OcelotKube/DownstreamService/DownstreamService.csproj
index 9a8d56e63..9d2379ec1 100644
--- a/samples/OcelotKube/DownstreamService/DownstreamService.csproj
+++ b/samples/OcelotKube/DownstreamService/DownstreamService.csproj
@@ -1,13 +1,13 @@
- net6.0
+ net7.0
InProcess
Linux
-
+
diff --git a/samples/OcelotKube/DownstreamService/Program.cs b/samples/OcelotKube/DownstreamService/Program.cs
index 03e1b8aea..462ccc9ac 100644
--- a/samples/OcelotKube/DownstreamService/Program.cs
+++ b/samples/OcelotKube/DownstreamService/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace DownstreamService
{
diff --git a/samples/OcelotKube/DownstreamService/Startup.cs b/samples/OcelotKube/DownstreamService/Startup.cs
index a8abb5d40..50b92cd2c 100644
--- a/samples/OcelotKube/DownstreamService/Startup.cs
+++ b/samples/OcelotKube/DownstreamService/Startup.cs
@@ -1,15 +1,9 @@
-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.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
namespace DownstreamService
{
diff --git a/samples/OcelotOpenTracing/OcelotOpenTracing.csproj b/samples/OcelotOpenTracing/OcelotOpenTracing.csproj
index 4c724b438..0384c8c01 100644
--- a/samples/OcelotOpenTracing/OcelotOpenTracing.csproj
+++ b/samples/OcelotOpenTracing/OcelotOpenTracing.csproj
@@ -2,12 +2,12 @@
Exe
- net6.0
+ net7.0
-
+
diff --git a/samples/OcelotOpenTracing/Program.cs b/samples/OcelotOpenTracing/Program.cs
index e9527930f..435e39883 100644
--- a/samples/OcelotOpenTracing/Program.cs
+++ b/samples/OcelotOpenTracing/Program.cs
@@ -1,16 +1,18 @@
namespace OcelotOpenTracing
{
+ using System.IO;
+
+ using Jaeger;
+
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
+ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
- using System.IO;
+ using Microsoft.Extensions.Logging;
+
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
- using Microsoft.Extensions.Logging;
using Ocelot.Tracing.OpenTracing;
- using Jaeger;
- using Microsoft.Extensions.DependencyInjection;
- using OpenTracing;
using OpenTracing.Util;
internal static class Program
@@ -35,10 +37,10 @@ private static void Main(string[] args)
})
.ConfigureServices((context, services) =>
{
- services.AddSingleton(sp =>
+ services.AddSingleton(sp =>
{
var loggerFactory = sp.GetService();
- Configuration config = new Configuration(context.HostingEnvironment.ApplicationName, loggerFactory);
+ var config = new Configuration(context.HostingEnvironment.ApplicationName, loggerFactory);
var tracer = config.GetTracer();
GlobalTracer.Register(tracer);
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.cs b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.cs
index 28ea7abbb..e218b6aed 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.cs
@@ -5,10 +5,11 @@
namespace OcelotApplicationApiGateway
{
+ using System.Collections.Generic;
using System.Fabric;
+
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
- using System.Collections.Generic;
/// Service that handles front-end web requests and acts as a proxy to the back-end data for the UI web page.
/// It is a stateless service that hosts a Web API application on OWIN.
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.csproj b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.csproj
index b9ad52cc0..10726f2ae 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.csproj
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/OcelotApplicationApiGateway.csproj
@@ -2,7 +2,7 @@
Stateless Web Service for Stateful OcelotApplicationApiGateway App
- net6.0
+ net7.0
OcelotApplicationApiGateway
Exe
OcelotApplicationApiGateway
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/Program.cs b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/Program.cs
index 7da30a50a..d8d563915 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/Program.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/Program.cs
@@ -7,10 +7,10 @@ namespace OcelotApplicationApiGateway
{
using System;
- using System.Fabric;
+ using System.Diagnostics.Tracing;
using System.Threading;
+
using Microsoft.ServiceFabric.Services.Runtime;
- using System.Diagnostics.Tracing;
///
@@ -25,7 +25,7 @@ public static void Main(string[] args)
{
//Creating a new event listener to redirect the traces to a file
- ServiceEventListener listener = new ServiceEventListener("OcelotApplicationApiGateway");
+ var listener = new ServiceEventListener("OcelotApplicationApiGateway");
listener.EnableEvents(ServiceEventSource.Current, EventLevel.LogAlways, EventKeywords.All);
// The ServiceManifest.XML file defines one or more service type names.
@@ -33,7 +33,7 @@ public static void Main(string[] args)
// When Service Fabric creates an instance of this service type,
// an instance of the class is created in this host process.
ServiceRuntime
- .RegisterServiceAsync("OcelotApplicationApiGatewayType", context => new OcelotServiceWebService (context))
+ .RegisterServiceAsync("OcelotApplicationApiGatewayType", context => new OcelotServiceWebService(context))
.GetAwaiter()
.GetResult();
@@ -44,8 +44,8 @@ public static void Main(string[] args)
catch (Exception ex)
{
ServiceEventSource.Current.ServiceHostInitializationFailed(ex);
- throw ex;
+ throw;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventListener.cs b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventListener.cs
index 555f9fde8..91dcf263d 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventListener.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventListener.cs
@@ -6,14 +6,10 @@
namespace OcelotApplicationApiGateway
{
using System;
- using System.IO;
- using System.Linq;
using System.Diagnostics.Tracing;
- using System.Fabric;
- using System.Fabric.Common;
- using System.Fabric.Common.Tracing;
- using Microsoft.ServiceFabric.Services.Runtime;
using System.Globalization;
+ using System.IO;
+ using System.Linq;
using System.Text;
///
@@ -24,12 +20,12 @@ namespace OcelotApplicationApiGateway
///
internal class ServiceEventListener : EventListener
{
- private string fileName;
- private string filepath = Path.GetTempPath();
+ private readonly string _fileName;
+ private readonly string _filepath = Path.GetTempPath();
public ServiceEventListener(string appName)
{
- this.fileName = appName + DateTime.Now.ToString("yyyyMMddHHmmssffff");
+ _fileName = appName + DateTime.Now.ToString("yyyyMMddHHmmssffff");
}
///
@@ -38,10 +34,10 @@ public ServiceEventListener(string appName)
/// The event arguments that describe the event.
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
- using (StreamWriter writer = new StreamWriter( new FileStream(filepath + fileName, FileMode.Append)))
+ using (var writer = new StreamWriter(new FileStream(_filepath + _fileName, FileMode.Append)))
{
// report all event information
- writer.Write(" {0} ", Write(eventData.Task.ToString(),
+ writer.Write(" {0} ", Write(eventData.Task.ToString(),
eventData.EventName,
eventData.EventId.ToString(),
eventData.Level));
@@ -55,9 +51,9 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
private static String Write(string taskName, string eventName, string id, EventLevel level)
{
- StringBuilder output = new StringBuilder();
+ var output = new StringBuilder();
- DateTime now = DateTime.UtcNow;
+ var now = DateTime.UtcNow;
output.Append(now.ToString("yyyy/MM/dd-HH:mm:ss.fff", CultureInfo.InvariantCulture));
output.Append(',');
output.Append(ConvertLevelToString(level));
@@ -91,4 +87,4 @@ private static string ConvertLevelToString(EventLevel level)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventSource.cs b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventSource.cs
index c05799556..002401c56 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventSource.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/ServiceEventSource.cs
@@ -7,15 +7,13 @@ namespace OcelotApplicationApiGateway
{
using System;
using System.Diagnostics.Tracing;
- using System.Fabric;
- using Microsoft.ServiceFabric.Services.Runtime;
///
/// Implements methods for logging service related events.
///
public class ServiceEventSource : EventSource
{
- public static ServiceEventSource Current = new ServiceEventSource();
+ public static ServiceEventSource Current = new();
// Define an instance method for each event you want to record and apply an [Event] attribute to it.
// The method name is the name of the event.
@@ -28,10 +26,10 @@ public class ServiceEventSource : EventSource
[NonEvent]
public void Message(string message, params object[] args)
{
- if (this.IsEnabled())
+ if (IsEnabled())
{
var finalMessage = string.Format(message, args);
- this.Message(finalMessage);
+ Message(finalMessage);
}
}
@@ -40,9 +38,9 @@ public void Message(string message, params object[] args)
[Event(MessageEventId, Level = EventLevel.Informational, Message = "{0}")]
public void Message(string message)
{
- if (this.IsEnabled())
+ if (IsEnabled())
{
- this.WriteEvent(MessageEventId, message);
+ WriteEvent(MessageEventId, message);
}
}
@@ -51,13 +49,13 @@ public void Message(string message)
[Event(ServiceTypeRegisteredEventId, Level = EventLevel.Informational, Message = "Service host process {0} registered service type {1}")]
public void ServiceTypeRegistered(int hostProcessId, string serviceType)
{
- this.WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);
+ WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);
}
[NonEvent]
public void ServiceHostInitializationFailed(Exception e)
{
- this.ServiceHostInitializationFailed(e.ToString());
+ ServiceHostInitializationFailed(e.ToString());
}
private const int ServiceHostInitializationFailedEventId = 4;
@@ -65,13 +63,13 @@ public void ServiceHostInitializationFailed(Exception e)
[Event(ServiceHostInitializationFailedEventId, Level = EventLevel.Error, Message = "Service host initialization failed: {0}")]
private void ServiceHostInitializationFailed(string exception)
{
- this.WriteEvent(ServiceHostInitializationFailedEventId, exception);
+ WriteEvent(ServiceHostInitializationFailedEventId, exception);
}
[NonEvent]
public void ServiceWebHostBuilderFailed(Exception e)
{
- this.ServiceWebHostBuilderFailed(e.ToString());
+ ServiceWebHostBuilderFailed(e.ToString());
}
private const int ServiceWebHostBuilderFailedEventId = 5;
@@ -79,7 +77,7 @@ public void ServiceWebHostBuilderFailed(Exception e)
[Event(ServiceWebHostBuilderFailedEventId, Level = EventLevel.Error, Message = "Service Owin Web Host Builder Failed: {0}")]
private void ServiceWebHostBuilderFailed(string exception)
{
- this.WriteEvent(ServiceWebHostBuilderFailedEventId, exception);
+ WriteEvent(ServiceWebHostBuilderFailedEventId, exception);
}
}
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/WebCommunicationListener.cs b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/WebCommunicationListener.cs
index c1f4a1730..11e84458f 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/WebCommunicationListener.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationApiGateway/WebCommunicationListener.cs
@@ -7,59 +7,58 @@ namespace OcelotApplicationApiGateway
{
using System;
using System.Fabric;
- using System.Fabric.Description;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Hosting;
- using Microsoft.ServiceFabric.Services.Communication.Runtime;
- using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.Extensions.DependencyInjection;
+ using Microsoft.Extensions.Logging;
+ using Microsoft.ServiceFabric.Services.Communication.Runtime;
+
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
public class WebCommunicationListener : ICommunicationListener
{
- private readonly string appRoot;
- private readonly ServiceContext serviceInitializationParameters;
- private string listeningAddress;
- private string publishAddress;
+ private readonly string _appRoot;
+ private readonly ServiceContext _serviceInitializationParameters;
+ private string _listeningAddress;
+ private string _publishAddress;
// OWIN server handle.
- private IWebHost webHost;
+ private IWebHost _webHost;
public WebCommunicationListener(string appRoot, ServiceContext serviceInitializationParameters)
{
- this.appRoot = appRoot;
- this.serviceInitializationParameters = serviceInitializationParameters;
+ _appRoot = appRoot;
+ _serviceInitializationParameters = serviceInitializationParameters;
}
public Task OpenAsync(CancellationToken cancellationToken)
{
ServiceEventSource.Current.Message("Initialize");
- EndpointResourceDescription serviceEndpoint = this.serviceInitializationParameters.CodePackageActivationContext.GetEndpoint("WebEndpoint");
- int port = serviceEndpoint.Port;
+ var serviceEndpoint = _serviceInitializationParameters.CodePackageActivationContext.GetEndpoint("WebEndpoint");
+ var port = serviceEndpoint.Port;
- this.listeningAddress = string.Format(
+ _listeningAddress = string.Format(
CultureInfo.InvariantCulture,
"http://+:{0}/{1}",
port,
- string.IsNullOrWhiteSpace(this.appRoot)
+ string.IsNullOrWhiteSpace(_appRoot)
? string.Empty
- : this.appRoot.TrimEnd('/') + '/');
+ : _appRoot.TrimEnd('/') + '/');
- this.publishAddress = this.listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);
+ _publishAddress = _listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);
- ServiceEventSource.Current.Message("Starting web server on {0}", this.listeningAddress);
+ ServiceEventSource.Current.Message("Starting web server on {0}", _listeningAddress);
try
{
- this.webHost = new WebHostBuilder()
+ _webHost = new WebHostBuilder()
.UseKestrel()
- .UseUrls(this.listeningAddress)
+ .UseUrls(_listeningAddress)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
@@ -74,33 +73,35 @@ public Task OpenAsync(CancellationToken cancellationToken)
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
})
- .ConfigureServices(s => {
+ .ConfigureServices(s =>
+ {
s.AddOcelot();
})
- .Configure(a => {
- a.UseOcelot().Wait();
+ .Configure(a =>
+ {
+ a.UseOcelot().Wait(cancellationToken);
})
.Build();
- this.webHost.Start();
+ _webHost.Start();
}
catch (Exception ex)
{
ServiceEventSource.Current.ServiceWebHostBuilderFailed(ex);
}
- return Task.FromResult(this.publishAddress);
+ return Task.FromResult(_publishAddress);
}
public Task CloseAsync(CancellationToken cancellationToken)
{
- this.StopAll();
+ StopAll();
return Task.FromResult(true);
}
public void Abort()
{
- this.StopAll();
+ StopAll();
}
///
@@ -110,10 +111,10 @@ private void StopAll()
{
try
{
- if (this.webHost != null)
+ if (_webHost != null)
{
ServiceEventSource.Current.Message("Stopping web server.");
- this.webHost.Dispose();
+ _webHost.Dispose();
}
}
catch (ObjectDisposedException)
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/ApiGateway.cs b/samples/OcelotServiceFabric/src/OcelotApplicationService/ApiGateway.cs
index 8c0908858..e7b7b5f7f 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/ApiGateway.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/ApiGateway.cs
@@ -2,15 +2,13 @@
using System.Collections.Generic;
using System.Fabric;
using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
using Microsoft.ServiceFabric.Services.Communication.AspNetCore;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
-using Microsoft.Extensions.Logging;
namespace OcelotApplicationService
{
@@ -31,7 +29,7 @@ protected override IEnumerable CreateServiceInstanceLis
{
return new ServiceInstanceListener[]
{
- new ServiceInstanceListener(serviceContext =>
+ new(serviceContext =>
new KestrelCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) =>
{
Console.WriteLine($"Starting Kestrel on {url}");
@@ -41,7 +39,7 @@ protected override IEnumerable CreateServiceInstanceLis
.UseKestrel()
.ConfigureServices(
services => services
- .AddSingleton(serviceContext))
+ .AddSingleton(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
.UseStartup()
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/Controllers/ValuesController.cs b/samples/OcelotServiceFabric/src/OcelotApplicationService/Controllers/ValuesController.cs
index 13e569993..b9d4958f3 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/Controllers/ValuesController.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/Controllers/ValuesController.cs
@@ -1,7 +1,5 @@
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Mvc;
namespace OcelotApplicationService.Controllers
@@ -13,7 +11,7 @@ public class ValuesController : Controller
[HttpGet]
public IEnumerable Get()
{
- return new string[] { "value1", "value2" };
+ return new[] { "value1", "value2" };
}
// GET api/values/5
@@ -25,13 +23,13 @@ public string Get(int id)
// POST api/values
[HttpPost]
- public void Post([FromBody]string value)
+ public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
- public void Put(int id, [FromBody]string value)
+ public void Put(int id, [FromBody] string value)
{
}
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/OcelotApplicationService.csproj b/samples/OcelotServiceFabric/src/OcelotApplicationService/OcelotApplicationService.csproj
index de03af3ea..7328d3e40 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/OcelotApplicationService.csproj
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/OcelotApplicationService.csproj
@@ -3,7 +3,7 @@
Stateless Service Application
Exe
- net6.0
+ net7.0
OcelotApplicationService
OcelotApplicationService
$(PackageTargetFallback)
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/Program.cs b/samples/OcelotServiceFabric/src/OcelotApplicationService/Program.cs
index b9d7d72e4..fcbf73387 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/Program.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/Program.cs
@@ -1,8 +1,8 @@
-using Microsoft.ServiceFabric.Services.Runtime;
using System;
using System.Diagnostics;
using System.Threading;
-using System.Threading.Tasks;
+
+using Microsoft.ServiceFabric.Services.Runtime;
namespace OcelotApplicationService
{
@@ -23,7 +23,7 @@ private static void Main()
ServiceRuntime.RegisterServiceAsync("OcelotApplicationServiceType",
context => new ApiGateway(context)).GetAwaiter().GetResult();
- ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ApiGateway).Name);
+ ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, nameof(ApiGateway));
// Prevents this host process from terminating so services keeps running.
Thread.Sleep(Timeout.Infinite);
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/ServiceEventSource.cs b/samples/OcelotServiceFabric/src/OcelotApplicationService/ServiceEventSource.cs
index 13e2df12a..f58ddcbcc 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/ServiceEventSource.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/ServiceEventSource.cs
@@ -1,9 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Fabric;
-using System.Linq;
-using System.Text;
using System.Threading.Tasks;
namespace OcelotApplicationService
@@ -11,7 +8,7 @@ namespace OcelotApplicationService
[EventSource(Name = "MyCompany-ServiceOcelotApplication-OcelotService")]
internal sealed class ServiceEventSource : EventSource
{
- public static readonly ServiceEventSource Current = new ServiceEventSource();
+ public static readonly ServiceEventSource Current = new();
static ServiceEventSource()
{
@@ -46,9 +43,9 @@ public static class Keywords
[NonEvent]
public void Message(string message, params object[] args)
{
- if (this.IsEnabled())
+ if (IsEnabled())
{
- string finalMessage = string.Format(message, args);
+ var finalMessage = string.Format(message, args);
Message(finalMessage);
}
}
@@ -57,7 +54,7 @@ public void Message(string message, params object[] args)
[Event(MessageEventId, Level = EventLevel.Informational, Message = "{0}")]
public void Message(string message)
{
- if (this.IsEnabled())
+ if (IsEnabled())
{
WriteEvent(MessageEventId, message);
}
@@ -66,10 +63,10 @@ public void Message(string message)
[NonEvent]
public void ServiceMessage(ServiceContext serviceContext, string message, params object[] args)
{
- if (this.IsEnabled())
+ if (IsEnabled())
{
- string finalMessage = string.Format(message, args);
+ var finalMessage = string.Format(message, args);
ServiceMessage(
serviceContext.ServiceName.ToString(),
serviceContext.ServiceTypeName,
@@ -157,14 +154,12 @@ public void ServiceRequestStop(string requestTypeName, string exception = "")
#region Private methods
private static long GetReplicaOrInstanceId(ServiceContext context)
{
- StatelessServiceContext stateless = context as StatelessServiceContext;
- if (stateless != null)
+ if (context is StatelessServiceContext stateless)
{
return stateless.InstanceId;
}
- StatefulServiceContext stateful = context as StatefulServiceContext;
- if (stateful != null)
+ if (context is StatefulServiceContext stateful)
{
return stateful.ReplicaId;
}
diff --git a/samples/OcelotServiceFabric/src/OcelotApplicationService/Startup.cs b/samples/OcelotServiceFabric/src/OcelotApplicationService/Startup.cs
index 022fcb0ee..0d9c56902 100644
--- a/samples/OcelotServiceFabric/src/OcelotApplicationService/Startup.cs
+++ b/samples/OcelotServiceFabric/src/OcelotApplicationService/Startup.cs
@@ -1,13 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
namespace OcelotApplicationService
{
diff --git a/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs b/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
index 0d2634630..ac21e8086 100644
--- a/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Administration/IdentityServerMiddlewareConfigurationProvider.cs
@@ -1,10 +1,13 @@
namespace Ocelot.Administration
{
+ using System.Threading.Tasks;
+
using Configuration.Repository;
+
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
- using Ocelot.Middleware;
- using System.Threading.Tasks;
+
+ using Middleware;
public static class IdentityServerMiddlewareConfigurationProvider
{
diff --git a/src/Ocelot.Administration/Ocelot.Administration.csproj b/src/Ocelot.Administration/Ocelot.Administration.csproj
index 8ec93dce9..3d13761bb 100644
--- a/src/Ocelot.Administration/Ocelot.Administration.csproj
+++ b/src/Ocelot.Administration/Ocelot.Administration.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
true
Provides Ocelot extensions to use the administration API and IdentityService dependencies that come with it
Ocelot.Administration
@@ -26,7 +26,7 @@
-
+
all
diff --git a/src/Ocelot.Administration/OcelotBuilderExtensions.cs b/src/Ocelot.Administration/OcelotBuilderExtensions.cs
index cf14fc1e4..23a93460b 100644
--- a/src/Ocelot.Administration/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Administration/OcelotBuilderExtensions.cs
@@ -1,17 +1,20 @@
-using Ocelot.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using System.Security.Cryptography.X509Certificates;
+
using IdentityServer4.AccessTokenValidation;
using IdentityServer4.Models;
+
+using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Configuration;
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;
-using System.Linq;
using Microsoft.IdentityModel.Tokens;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
+
+using Ocelot.DependencyInjection;
+using Ocelot.Middleware;
namespace Ocelot.Administration
{
@@ -21,7 +24,7 @@ public static IOcelotAdministrationBuilder AddAdministration(this IOcelotBuilder
{
var administrationPath = new AdministrationPath(path);
- builder.Services.AddSingleton(IdentityServerMiddlewareConfigurationProvider.Get);
+ builder.Services.AddSingleton(IdentityServerMiddlewareConfigurationProvider.Get);
//add identity server for admin area
var identityServerConfiguration = IdentityServerConfigurationCreator.GetIdentityServerConfiguration(secret);
@@ -38,7 +41,7 @@ public static IOcelotAdministrationBuilder AddAdministration(this IOcelotBuilder
public static IOcelotAdministrationBuilder AddAdministration(this IOcelotBuilder builder, string path, Action configureOptions)
{
var administrationPath = new AdministrationPath(path);
- builder.Services.AddSingleton(IdentityServerMiddlewareConfigurationProvider.Get);
+ builder.Services.AddSingleton(IdentityServerMiddlewareConfigurationProvider.Get);
if (configureOptions != null)
{
@@ -58,7 +61,7 @@ private static void AddIdentityServer(Action configOptions, IO
private static void AddIdentityServer(IIdentityServerConfiguration identityServerConfiguration, IAdministrationPath adminPath, IOcelotBuilder builder, IConfiguration configuration)
{
- builder.Services.TryAddSingleton(identityServerConfiguration);
+ builder.Services.TryAddSingleton(identityServerConfiguration);
var identityServerBuilder = builder.Services
.AddIdentityServer(o =>
{
@@ -108,11 +111,11 @@ private static List Resources(IIdentityServerConfiguration identity
{
return new List
{
- new ApiResource(identityServerConfiguration.ApiName, identityServerConfiguration.ApiName)
+ new(identityServerConfiguration.ApiName, identityServerConfiguration.ApiName)
{
ApiSecrets = new List
{
- new Secret
+ new()
{
Value = identityServerConfiguration.ApiSecret.Sha256(),
},
@@ -125,11 +128,11 @@ private static List Client(IIdentityServerConfiguration identityServerCo
{
return new List
{
- new Client
+ new()
{
ClientId = identityServerConfiguration.ApiName,
AllowedGrantTypes = GrantTypes.ClientCredentials,
- ClientSecrets = new List {new Secret(identityServerConfiguration.ApiSecret.Sha256())},
+ ClientSecrets = new List {new(identityServerConfiguration.ApiSecret.Sha256())},
AllowedScopes = identityServerConfiguration.AllowedScopes,
},
};
diff --git a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
index 2e020cfad..08863e6bd 100644
--- a/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
+++ b/src/Ocelot.Cache.CacheManager/Ocelot.Cache.CacheManager.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
true
Provides Ocelot extensions to use CacheManager.Net
Ocelot.Cache.CacheManager
@@ -26,7 +26,7 @@
-
+
all
diff --git a/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs b/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
index 7a2c2d868..600394f3c 100644
--- a/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Cache.CacheManager/OcelotBuilderExtensions.cs
@@ -1,12 +1,16 @@
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
{
@@ -17,21 +21,21 @@ public static IOcelotBuilder AddCacheManager(this IOcelotBuilder builder, Action
builder.Services.RemoveAll(typeof(ICacheManager));
builder.Services.RemoveAll(typeof(IOcelotCache));
- builder.Services.AddSingleton>(cacheManagerOutputCache);
+ builder.Services.AddSingleton(cacheManagerOutputCache);
builder.Services.AddSingleton>(ocelotOutputCacheManager);
var ocelotConfigCacheManagerOutputCache = CacheFactory.Build("OcelotConfigurationCache", settings);
var ocelotConfigCacheManager = new OcelotCacheManagerCache(ocelotConfigCacheManagerOutputCache);
builder.Services.RemoveAll(typeof(ICacheManager));
builder.Services.RemoveAll(typeof(IOcelotCache));
- builder.Services.AddSingleton>(ocelotConfigCacheManagerOutputCache);
+ builder.Services.AddSingleton(ocelotConfigCacheManagerOutputCache);
builder.Services.AddSingleton>(ocelotConfigCacheManager);
var fileConfigCacheManagerOutputCache = CacheFactory.Build("FileConfigurationCache", settings);
var fileConfigCacheManager = new OcelotCacheManagerCache(fileConfigCacheManagerOutputCache);
builder.Services.RemoveAll(typeof(ICacheManager));
builder.Services.RemoveAll(typeof(IOcelotCache));
- builder.Services.AddSingleton>(fileConfigCacheManagerOutputCache);
+ builder.Services.AddSingleton(fileConfigCacheManagerOutputCache);
builder.Services.AddSingleton>(fileConfigCacheManager);
builder.Services.RemoveAll(typeof(ICacheKeyGenerator));
diff --git a/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs b/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
index a95df4c4f..b8e8fe295 100644
--- a/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
+++ b/src/Ocelot.Cache.CacheManager/OcelotCacheManagerCache.cs
@@ -1,8 +1,9 @@
namespace Ocelot.Cache.CacheManager
{
- using global::CacheManager.Core;
using System;
+ using global::CacheManager.Core;
+
public class OcelotCacheManagerCache : IOcelotCache
{
private readonly ICacheManager _cacheManager;
diff --git a/src/Ocelot.Provider.Consul/Consul.cs b/src/Ocelot.Provider.Consul/Consul.cs
index 72f15d095..22011f512 100644
--- a/src/Ocelot.Provider.Consul/Consul.cs
+++ b/src/Ocelot.Provider.Consul/Consul.cs
@@ -1,13 +1,18 @@
namespace Ocelot.Provider.Consul
{
- 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 global::Consul;
+
+ using Infrastructure.Extensions;
+
+ using Logging;
+
+ using ServiceDiscovery.Providers;
+
using Values;
public class Consul : IServiceDiscoveryProvider
@@ -54,7 +59,7 @@ public async Task> Get()
return services.ToList();
}
- private Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
+ private static Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
{
return new Service(
serviceEntry.Service.Service,
@@ -64,7 +69,7 @@ private Service BuildService(ServiceEntry serviceEntry, Node serviceNode)
serviceEntry.Service.Tags ?? Enumerable.Empty());
}
- private bool IsValid(ServiceEntry serviceEntry)
+ private static bool IsValid(ServiceEntry serviceEntry)
{
if (string.IsNullOrEmpty(serviceEntry.Service.Address) || serviceEntry.Service.Address.Contains("http://") || serviceEntry.Service.Address.Contains("https://") || serviceEntry.Service.Port <= 0)
{
@@ -74,7 +79,7 @@ private bool IsValid(ServiceEntry serviceEntry)
return true;
}
- private string GetVersionFromStrings(IEnumerable strings)
+ private static string GetVersionFromStrings(IEnumerable strings)
{
return strings
?.FirstOrDefault(x => x.StartsWith(VersionPrefix, StringComparison.Ordinal))
diff --git a/src/Ocelot.Provider.Consul/ConsulClientFactory.cs b/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
index 94055df79..089ff0e5d 100644
--- a/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
+++ b/src/Ocelot.Provider.Consul/ConsulClientFactory.cs
@@ -1,8 +1,9 @@
namespace Ocelot.Provider.Consul
{
- using global::Consul;
using System;
+ using global::Consul;
+
public class ConsulClientFactory : IConsulClientFactory
{
public IConsulClient Get(ConsulRegistryConfiguration config)
diff --git a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
index 56e55dfe7..b512f38c6 100644
--- a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
+++ b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
@@ -1,15 +1,21 @@
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 Microsoft.Extensions.Options;
+
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 1b89b4f33..cfc064dea 100644
--- a/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs
@@ -1,16 +1,20 @@
namespace Ocelot.Provider.Consul
{
+ using System;
+ using System.Linq;
+ using System.Threading.Tasks;
+
using Configuration.Creator;
using Configuration.File;
using Configuration.Repository;
+
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
+
using Middleware;
+
using Responses;
- using System;
- using System.Linq;
- using System.Threading.Tasks;
public static class ConsulMiddlewareConfigurationProvider
{
@@ -77,7 +81,7 @@ private static async Task SetFileConfigInConsul(IApplicationBuilder builder,
private static void ThrowToStopOcelotStarting(Response config)
{
- throw new Exception($"Unable to start Ocelot, errors are: {string.Join(",", config.Errors.Select(x => x.ToString()))}");
+ throw new Exception($"Unable to start Ocelot, errors are: {string.Join(',', config.Errors.Select(x => x.ToString()))}");
}
private static bool IsError(Response response)
diff --git a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
index ac1f2dfb0..b911e8309 100644
--- a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
+++ b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
@@ -1,7 +1,9 @@
namespace Ocelot.Provider.Consul
{
- using Logging;
- using Microsoft.Extensions.DependencyInjection;
+ using Logging;
+
+ using Microsoft.Extensions.DependencyInjection;
+
using ServiceDiscovery;
public static class ConsulProviderFactory
diff --git a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
index 237cb59d4..d3fb63b87 100644
--- a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
+++ b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
true
Provides Ocelot extensions to use Consul
Ocelot.Provider.Consul
@@ -26,8 +26,8 @@
-
-
+
+
all
diff --git a/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
index ce2ed95bb..13e5401ee 100644
--- a/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Consul/OcelotBuilderExtensions.cs
@@ -1,17 +1,17 @@
namespace Ocelot.Provider.Consul
{
using Configuration.Repository;
+
using DependencyInjection;
+
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
- using Middleware;
- using ServiceDiscovery;
public static class OcelotBuilderExtensions
{
public static IOcelotBuilder AddConsul(this IOcelotBuilder builder)
{
- builder.Services.AddSingleton(ConsulProviderFactory.Get);
+ builder.Services.AddSingleton(ConsulProviderFactory.Get);
builder.Services.AddSingleton();
builder.Services.RemoveAll(typeof(IFileConfigurationPollerOptions));
builder.Services.AddSingleton();
@@ -20,7 +20,7 @@ public static IOcelotBuilder AddConsul(this IOcelotBuilder builder)
public static IOcelotBuilder AddConfigStoredInConsul(this IOcelotBuilder builder)
{
- builder.Services.AddSingleton(ConsulMiddlewareConfigurationProvider.Get);
+ builder.Services.AddSingleton(ConsulMiddlewareConfigurationProvider.Get);
builder.Services.AddHostedService();
builder.Services.AddSingleton();
return builder;
diff --git a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
index 5bace8021..9b320736c 100644
--- a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
+++ b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs
@@ -1,11 +1,14 @@
namespace Ocelot.Provider.Consul
{
- using Logging;
- using ServiceDiscovery.Providers;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+
+ using Logging;
+
+ using ServiceDiscovery.Providers;
+
using Values;
public sealed class PollConsul : IServiceDiscoveryProvider, IDisposable
diff --git a/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs b/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
index a0f0579cd..7b55665d2 100644
--- a/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
+++ b/src/Ocelot.Provider.Consul/UnableToSetConfigInConsulError.cs
@@ -1,6 +1,6 @@
namespace Ocelot.Provider.Consul
{
- using Ocelot.Errors;
+ using Errors;
public class UnableToSetConfigInConsulError : Error
{
diff --git a/src/Ocelot.Provider.Eureka/Eureka.cs b/src/Ocelot.Provider.Eureka/Eureka.cs
index 9da8decd1..4eebe40a3 100644
--- a/src/Ocelot.Provider.Eureka/Eureka.cs
+++ b/src/Ocelot.Provider.Eureka/Eureka.cs
@@ -1,11 +1,13 @@
namespace Ocelot.Provider.Eureka
{
- using Ocelot.ServiceDiscovery.Providers;
- using Steeltoe.Discovery;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
- using Ocelot.Values;
+
+ using ServiceDiscovery.Providers;
+ using Values;
+
+ using Steeltoe.Discovery;
public class Eureka : IServiceDiscoveryProvider
{
@@ -26,7 +28,7 @@ public Task> Get()
if (instances != null && instances.Any())
{
- services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), "", "", new List())));
+ services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), string.Empty, string.Empty, new List())));
}
return Task.FromResult(services);
diff --git a/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs b/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
index f893ed722..776a4999d 100644
--- a/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
+++ b/src/Ocelot.Provider.Eureka/EurekaMiddlewareConfigurationProvider.cs
@@ -1,11 +1,15 @@
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 13e6fc8f8..887f1a987 100644
--- a/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs
+++ b/src/Ocelot.Provider.Eureka/EurekaProviderFactory.cs
@@ -1,7 +1,9 @@
namespace Ocelot.Provider.Eureka
{
using Microsoft.Extensions.DependencyInjection;
- using Ocelot.ServiceDiscovery;
+
+ using ServiceDiscovery;
+
using Steeltoe.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 e828b6ccd..637d42f39 100644
--- a/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj
+++ b/src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
true
Provides Ocelot extensions to use Eureka
Ocelot.Provider.Eureka
@@ -27,9 +27,9 @@
-
-
-
+
+
+
all
diff --git a/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
index e141d1947..61c03a96f 100644
--- a/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Eureka/OcelotBuilderExtensions.cs
@@ -1,20 +1,17 @@
namespace Ocelot.Provider.Eureka
{
using DependencyInjection;
- using Microsoft.Extensions.Configuration;
+
using Microsoft.Extensions.DependencyInjection;
- using Middleware;
- using ServiceDiscovery;
using Steeltoe.Discovery.Client;
- using System.Linq;
public static class OcelotBuilderExtensions
{
public static IOcelotBuilder AddEureka(this IOcelotBuilder builder)
{
builder.Services.AddDiscoveryClient(builder.Configuration);
- builder.Services.AddSingleton(EurekaProviderFactory.Get);
- builder.Services.AddSingleton(EurekaMiddlewareConfigurationProvider.Get);
+ builder.Services.AddSingleton(EurekaProviderFactory.Get);
+ builder.Services.AddSingleton(EurekaMiddlewareConfigurationProvider.Get);
return builder;
}
}
diff --git a/src/Ocelot.Provider.Kubernetes/KubeApiClientExtensions/EndPointClientV1.cs b/src/Ocelot.Provider.Kubernetes/KubeApiClientExtensions/EndPointClientV1.cs
index 3e384d32d..d29ec6d2f 100644
--- a/src/Ocelot.Provider.Kubernetes/KubeApiClientExtensions/EndPointClientV1.cs
+++ b/src/Ocelot.Provider.Kubernetes/KubeApiClientExtensions/EndPointClientV1.cs
@@ -1,10 +1,12 @@
-using HTTPlease;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+using HTTPlease;
+
using KubeClient;
using KubeClient.Models;
using KubeClient.ResourceClients;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
namespace Ocelot.Provider.Kubernetes.KubeApiClientExtensions
{
diff --git a/src/Ocelot.Provider.Kubernetes/KubeProvider.cs b/src/Ocelot.Provider.Kubernetes/KubeProvider.cs
index 927e4eead..87bbec906 100644
--- a/src/Ocelot.Provider.Kubernetes/KubeProvider.cs
+++ b/src/Ocelot.Provider.Kubernetes/KubeProvider.cs
@@ -1,12 +1,14 @@
-using KubeClient;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+using KubeClient;
using KubeClient.Models;
+
using Ocelot.Logging;
+using Ocelot.Provider.Kubernetes.KubeApiClientExtensions;
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Ocelot.Provider.Kubernetes.KubeApiClientExtensions;
namespace Ocelot.Provider.Kubernetes
{
@@ -36,12 +38,12 @@ public async Task> Get()
}
else
{
- _logger.LogWarning($"namespace:{_kubeRegistryConfiguration.KubeNamespace }service:{_kubeRegistryConfiguration.KeyOfServiceInK8s} Unable to use ,it is invalid. Address must contain host only e.g. localhost and port must be greater than 0");
+ _logger.LogWarning($"namespace:{_kubeRegistryConfiguration.KubeNamespace}service:{_kubeRegistryConfiguration.KeyOfServiceInK8s} Unable to use ,it is invalid. Address must contain host only e.g. localhost and port must be greater than 0");
}
return services;
}
- private List BuildServices(EndpointsV1 endpoint)
+ private static List BuildServices(EndpointsV1 endpoint)
{
var services = new List();
diff --git a/src/Ocelot.Provider.Kubernetes/KubernetesProviderFactory.cs b/src/Ocelot.Provider.Kubernetes/KubernetesProviderFactory.cs
index 0927ed6dc..bb5828916 100644
--- a/src/Ocelot.Provider.Kubernetes/KubernetesProviderFactory.cs
+++ b/src/Ocelot.Provider.Kubernetes/KubernetesProviderFactory.cs
@@ -1,9 +1,12 @@
-using KubeClient;
+using System;
+
+using KubeClient;
+
using Microsoft.Extensions.DependencyInjection;
+
+using Ocelot.Configuration;
using Ocelot.Logging;
using Ocelot.ServiceDiscovery;
-using System;
-using Ocelot.Configuration;
namespace Ocelot.Provider.Kubernetes
{
@@ -19,7 +22,7 @@ private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetKubeProvi
{
var kubeClient = provider.GetService();
- var k8sRegistryConfiguration = new KubeRegistryConfiguration()
+ var k8sRegistryConfiguration = new KubeRegistryConfiguration
{
KeyOfServiceInK8s = route.ServiceName,
KubeNamespace = string.IsNullOrEmpty(route.ServiceNamespace) ? config.Namespace : route.ServiceNamespace
diff --git a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
index b1d87ae34..32dfebe3b 100644
--- a/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
+++ b/src/Ocelot.Provider.Kubernetes/Ocelot.Provider.Kubernetes.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
true
Ocelot
Provides Ocelot extensions to use kubernetes
@@ -28,8 +28,8 @@
-
-
+
+
diff --git a/src/Ocelot.Provider.Kubernetes/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Kubernetes/OcelotBuilderExtensions.cs
index f979586a5..958b4929e 100644
--- a/src/Ocelot.Provider.Kubernetes/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Kubernetes/OcelotBuilderExtensions.cs
@@ -1,5 +1,7 @@
using KubeClient;
+
using Microsoft.Extensions.DependencyInjection;
+
using Ocelot.DependencyInjection;
namespace Ocelot.Provider.Kubernetes
diff --git a/src/Ocelot.Provider.Kubernetes/PollKubernetes.cs b/src/Ocelot.Provider.Kubernetes/PollKubernetes.cs
index b1a90596e..cd0e854f4 100644
--- a/src/Ocelot.Provider.Kubernetes/PollKubernetes.cs
+++ b/src/Ocelot.Provider.Kubernetes/PollKubernetes.cs
@@ -1,10 +1,11 @@
-using Ocelot.Logging;
-using Ocelot.ServiceDiscovery.Providers;
-using Ocelot.Values;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
+using Ocelot.Logging;
+using Ocelot.ServiceDiscovery.Providers;
+using Ocelot.Values;
+
namespace Ocelot.Provider.Kubernetes
{
public class PollKubernetes : IServiceDiscoveryProvider
diff --git a/src/Ocelot.Provider.Polly/CircuitBreaker.cs b/src/Ocelot.Provider.Polly/CircuitBreaker.cs
index 8d4c6d4c1..4c9a1ea67 100644
--- a/src/Ocelot.Provider.Polly/CircuitBreaker.cs
+++ b/src/Ocelot.Provider.Polly/CircuitBreaker.cs
@@ -1,21 +1,22 @@
-using Polly;
using System.Collections.Generic;
using System.Linq;
+using Polly;
+
namespace Ocelot.Provider.Polly
{
public class CircuitBreaker
{
- private readonly List _policies = new List();
+ private readonly List _policies = new();
public CircuitBreaker(params IAsyncPolicy[] policies)
{
foreach (var policy in policies.Where(p => p != null))
{
- this._policies.Add(policy);
+ _policies.Add(policy);
}
}
- public IAsyncPolicy[] Policies => this._policies.ToArray();
+ public IAsyncPolicy[] Policies => _policies.ToArray();
}
}
diff --git a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
index 9b8342024..432e7407d 100644
--- a/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
+++ b/src/Ocelot.Provider.Polly/Ocelot.Provider.Polly.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net7.0
true
Provides Ocelot extensions to use Polly.NET
Ocelot.Provider.Polly
@@ -27,7 +27,7 @@
-
+
all
diff --git a/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs b/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
index 08c892d3d..30bc7d3a0 100644
--- a/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Provider.Polly/OcelotBuilderExtensions.cs
@@ -1,17 +1,24 @@
namespace Ocelot.Provider.Polly
{
- using Configuration;
- using DependencyInjection;
- using Errors;
- using global::Polly.CircuitBreaker;
- using global::Polly.Timeout;
- using Logging;
- using Microsoft.Extensions.DependencyInjection;
- using Requester;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
+
+ using Configuration;
+
+ using DependencyInjection;
+
+ using Errors;
+
+ using global::Polly.CircuitBreaker;
+ using global::Polly.Timeout;
+
+ using Logging;
+
+ using Microsoft.Extensions.DependencyInjection;
+
+ using Requester;
public static class OcelotBuilderExtensions
{
diff --git a/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs b/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
index 8bdcaa4a7..43841c0a6 100644
--- a/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
+++ b/src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
@@ -1,10 +1,12 @@
-using Ocelot.Logging;
-using Polly;
-using Polly.CircuitBreaker;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+using Ocelot.Logging;
+
+using Polly;
+using Polly.CircuitBreaker;
+
namespace Ocelot.Provider.Polly
{
public class PollyCircuitBreakingDelegatingHandler : DelegatingHandler
@@ -30,12 +32,12 @@ protected override async Task SendAsync(HttpRequestMessage
}
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)
{
- _logger.LogError($"Error in CircuitBreakingDelegatingHandler.SendAync", ex);
+ _logger.LogError("Error in CircuitBreakingDelegatingHandler.SendAync", ex);
throw;
}
}
diff --git a/src/Ocelot.Provider.Polly/PollyQoSProvider.cs b/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
index def8c7d85..1e0522041 100644
--- a/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
+++ b/src/Ocelot.Provider.Polly/PollyQoSProvider.cs
@@ -1,12 +1,14 @@
namespace Ocelot.Provider.Polly
{
- using global::Polly;
- using global::Polly.CircuitBreaker;
- using global::Polly.Timeout;
- using Ocelot.Configuration;
- using Ocelot.Logging;
using System;
using System.Net.Http;
+
+ using global::Polly;
+ using global::Polly.CircuitBreaker;
+ using global::Polly.Timeout;
+
+ using Configuration;
+ using Logging;
public class PollyQoSProvider
{
diff --git a/src/Ocelot.Provider.Polly/RequestTimedOutError.cs b/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
index 3c52a8dd0..73d105d62 100644
--- a/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
+++ b/src/Ocelot.Provider.Polly/RequestTimedOutError.cs
@@ -1,8 +1,9 @@
namespace Ocelot.Provider.Polly
{
- using Ocelot.Errors;
using System;
+ using Errors;
+
public class RequestTimedOutError : Error
{
public RequestTimedOutError(Exception exception)
diff --git a/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs b/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
index 3cd63eb0a..9ee80bfd1 100644
--- a/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
+++ b/src/Ocelot.Tracing.Butterfly/ButterflyTracer.cs
@@ -1,11 +1,5 @@
namespace Ocelot.Tracing.Butterfly
{
- 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;
@@ -13,6 +7,15 @@
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;
+
public class ButterflyTracer : DelegatingHandler, Logging.ITracer
{
private readonly IServiceTracer _tracer;
diff --git a/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj b/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj
index f1a09eac3..cade59983 100644
--- a/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj
+++ b/src/Ocelot.Tracing.Butterfly/Ocelot.Tracing.Butterfly.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
true
This package provides methods to integrate Butterfly tracing with Ocelot.
Ocelot.Tracing.Butterfly
diff --git a/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs b/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
index 8c67f0dfa..e15f382da 100644
--- a/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Tracing.Butterfly/OcelotBuilderExtensions.cs
@@ -1,10 +1,14 @@
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.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj b/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj
index 866f295b8..06f67fe66 100644
--- a/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj
+++ b/src/Ocelot.Tracing.OpenTracing/Ocelot.Tracing.OpenTracing.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
0.0.0-dev
Kjell-Åke Gafvelin
This package provides OpenTracing support to Ocelot.
diff --git a/src/Ocelot.Tracing.OpenTracing/OcelotBuilderExtensions.cs b/src/Ocelot.Tracing.OpenTracing/OcelotBuilderExtensions.cs
index 59d789758..90c781bb8 100644
--- a/src/Ocelot.Tracing.OpenTracing/OcelotBuilderExtensions.cs
+++ b/src/Ocelot.Tracing.OpenTracing/OcelotBuilderExtensions.cs
@@ -1,8 +1,9 @@
namespace Ocelot.Tracing.OpenTracing
{
using Microsoft.Extensions.DependencyInjection.Extensions;
- using Ocelot.DependencyInjection;
- using Ocelot.Logging;
+
+ using DependencyInjection;
+ using Logging;
public static class OcelotBuilderExtensions
{
diff --git a/src/Ocelot.Tracing.OpenTracing/OpenTracingTracer.cs b/src/Ocelot.Tracing.OpenTracing/OpenTracingTracer.cs
index 744e6ddd3..b2e0222bc 100644
--- a/src/Ocelot.Tracing.OpenTracing/OpenTracingTracer.cs
+++ b/src/Ocelot.Tracing.OpenTracing/OpenTracingTracer.cs
@@ -1,36 +1,38 @@
namespace Ocelot.Tracing.OpenTracing
{
- using global::OpenTracing;
- using global::OpenTracing.Propagation;
- using global::OpenTracing.Tag;
- using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+ using global::OpenTracing;
+ using global::OpenTracing.Propagation;
+ using global::OpenTracing.Tag;
+
+ using Microsoft.AspNetCore.Http;
+
class OpenTracingTracer : Logging.ITracer
{
private readonly ITracer _tracer;
public OpenTracingTracer(ITracer tracer)
{
- _tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
+ _tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
}
public void Event(HttpContext httpContext, string @event)
{
}
- public async Task SendAsync(HttpRequestMessage request,
+ public async Task SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken,
- Action addTraceIdToRepo,
- Func addTraceIdToRepo,
+ Func> baseSendAsync)
{
- using (IScope scope = _tracer.BuildSpan(request.RequestUri.AbsoluteUri).StartActive(finishSpanOnDispose: true))
+ using (var scope = _tracer.BuildSpan(request.RequestUri.AbsoluteUri).StartActive(finishSpanOnDispose: true))
{
var span = scope.Span;
diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
index 2eba74293..7ec564210 100644
--- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
+++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs
@@ -1,12 +1,13 @@
namespace Ocelot.Authentication.Middleware
{
- using Microsoft.AspNetCore.Http;
+ using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Authentication;
- using Ocelot.Configuration;
- using Ocelot.Logging;
+ using Microsoft.AspNetCore.Http;
+
+ using Configuration;
+ using Logging;
using Ocelot.Middleware;
- using System.Threading.Tasks;
- using Ocelot.DownstreamRouteFinder.Middleware;
public class AuthenticationMiddleware : OcelotMiddleware
{
diff --git a/src/Ocelot/Authorization/ClaimValueNotAuthorizedError.cs b/src/Ocelot/Authorization/ClaimValueNotAuthorizedError.cs
index c4d4e8144..ab2d586d6 100644
--- a/src/Ocelot/Authorization/ClaimValueNotAuthorizedError.cs
+++ b/src/Ocelot/Authorization/ClaimValueNotAuthorizedError.cs
@@ -1,7 +1,6 @@
namespace Ocelot.Authorization
{
- using Ocelot.Errors;
- using System.Net;
+ using Errors;
public class ClaimValueNotAuthorizedError : Error
{
diff --git a/src/Ocelot/Authorization/ClaimsAuthorizer.cs b/src/Ocelot/Authorization/ClaimsAuthorizer.cs
index 15da73d74..fec621362 100644
--- a/src/Ocelot/Authorization/ClaimsAuthorizer.cs
+++ b/src/Ocelot/Authorization/ClaimsAuthorizer.cs
@@ -1,13 +1,14 @@
namespace Ocelot.Authorization
{
- using Ocelot.Infrastructure.Claims.Parser;
- using Ocelot.DownstreamRouteFinder.UrlMatcher;
- using Ocelot.Responses;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.RegularExpressions;
+ using DownstreamRouteFinder.UrlMatcher;
+ using Ocelot.Infrastructure.Claims.Parser;
+ using Responses;
+
public class ClaimsAuthorizer : IClaimsAuthorizer
{
private readonly IClaimsParser _claimsParser;
diff --git a/src/Ocelot/Authorization/IClaimsAuthorizer.cs b/src/Ocelot/Authorization/IClaimsAuthorizer.cs
index dc89f0109..4c49a93de 100644
--- a/src/Ocelot/Authorization/IClaimsAuthorizer.cs
+++ b/src/Ocelot/Authorization/IClaimsAuthorizer.cs
@@ -1,6 +1,7 @@
-using Ocelot.DownstreamRouteFinder.UrlMatcher;
-using Ocelot.Responses;
-using System.Security.Claims;
+using System.Security.Claims;
+
+using Ocelot.DownstreamRouteFinder.UrlMatcher;
+using Ocelot.Responses;
namespace Ocelot.Authorization
{
diff --git a/src/Ocelot/Authorization/IScopesAuthorizer.cs b/src/Ocelot/Authorization/IScopesAuthorizer.cs
index e0041cd28..3b0c171c1 100644
--- a/src/Ocelot/Authorization/IScopesAuthorizer.cs
+++ b/src/Ocelot/Authorization/IScopesAuthorizer.cs
@@ -1,5 +1,6 @@
-using Ocelot.Responses;
-using System.Security.Claims;
+using System.Security.Claims;
+
+using Ocelot.Responses;
namespace Ocelot.Authorization
{
diff --git a/src/Ocelot/Authorization/Middleware/AuthorizationMiddleware.cs b/src/Ocelot/Authorization/Middleware/AuthorizationMiddleware.cs
index 3a9c5d802..24ef10233 100644
--- a/src/Ocelot/Authorization/Middleware/AuthorizationMiddleware.cs
+++ b/src/Ocelot/Authorization/Middleware/AuthorizationMiddleware.cs
@@ -1,12 +1,13 @@
namespace Ocelot.Authorization.Middleware
{
- using Ocelot.Configuration;
- using Ocelot.Logging;
- using Ocelot.Middleware;
- using Ocelot.Responses;
using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Http;
- using Ocelot.DownstreamRouteFinder.Middleware;
+
+ using Configuration;
+ using Logging;
+ using Ocelot.Middleware;
+ using Responses;
public class AuthorizationMiddleware : OcelotMiddleware
{
diff --git a/src/Ocelot/Authorization/ScopeNotAuthorizedError.cs b/src/Ocelot/Authorization/ScopeNotAuthorizedError.cs
index dc5823a32..80eedc0a0 100644
--- a/src/Ocelot/Authorization/ScopeNotAuthorizedError.cs
+++ b/src/Ocelot/Authorization/ScopeNotAuthorizedError.cs
@@ -1,6 +1,6 @@
namespace Ocelot.Authorization
{
- using Ocelot.Errors;
+ using Errors;
public class ScopeNotAuthorizedError : Error
{
diff --git a/src/Ocelot/Authorization/ScopesAuthorizer.cs b/src/Ocelot/Authorization/ScopesAuthorizer.cs
index 7fd7e2aaf..73b4b8ed3 100644
--- a/src/Ocelot/Authorization/ScopesAuthorizer.cs
+++ b/src/Ocelot/Authorization/ScopesAuthorizer.cs
@@ -1,7 +1,8 @@
-using Ocelot.Responses;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
+
+using Ocelot.Responses;
namespace Ocelot.Authorization
{
@@ -10,7 +11,7 @@ namespace Ocelot.Authorization
public class ScopesAuthorizer : IScopesAuthorizer
{
private readonly IClaimsParser _claimsParser;
- private readonly string _scope = "scope";
+ private const string Scope = "scope";
public ScopesAuthorizer(IClaimsParser claimsParser)
{
@@ -24,7 +25,7 @@ public Response Authorize(ClaimsPrincipal claimsPrincipal, List ro
return new OkResponse(true);
}
- var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, _scope);
+ var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, Scope);
if (values.IsError)
{
@@ -33,12 +34,12 @@ public Response Authorize(ClaimsPrincipal claimsPrincipal, List ro
var userScopes = values.Data;
- var matchesScopes = routeAllowedScopes.Intersect(userScopes).ToList();
+ var matchesScopes = routeAllowedScopes.Intersect(userScopes);
- if (matchesScopes.Count == 0)
+ if (!matchesScopes.Any())
{
return new ErrorResponse(
- new ScopeNotAuthorizedError($"no one user scope: '{string.Join(",", userScopes)}' match with some allowed scope: '{string.Join(",", routeAllowedScopes)}'"));
+ new ScopeNotAuthorizedError($"no one user scope: '{string.Join(',', userScopes)}' match with some allowed scope: '{string.Join(',', routeAllowedScopes)}'"));
}
return new OkResponse(true);
diff --git a/src/Ocelot/Authorization/UnauthorizedError.cs b/src/Ocelot/Authorization/UnauthorizedError.cs
index 689f9e2f2..034f94dc6 100644
--- a/src/Ocelot/Authorization/UnauthorizedError.cs
+++ b/src/Ocelot/Authorization/UnauthorizedError.cs
@@ -1,6 +1,6 @@
namespace Ocelot.Authorization
{
- using Ocelot.Errors;
+ using Errors;
public class UnauthorizedError : Error
{
diff --git a/src/Ocelot/Authorization/UserDoesNotHaveClaimError.cs b/src/Ocelot/Authorization/UserDoesNotHaveClaimError.cs
index 08c19d9f8..9ce1586c9 100644
--- a/src/Ocelot/Authorization/UserDoesNotHaveClaimError.cs
+++ b/src/Ocelot/Authorization/UserDoesNotHaveClaimError.cs
@@ -1,6 +1,6 @@
namespace Ocelot.Authorization
{
- using Ocelot.Errors;
+ using Errors;
public class UserDoesNotHaveClaimError : Error
{
diff --git a/src/Ocelot/Cache/AspMemoryCache.cs b/src/Ocelot/Cache/AspMemoryCache.cs
index 6a28dbbfc..ba8513be3 100644
--- a/src/Ocelot/Cache/AspMemoryCache.cs
+++ b/src/Ocelot/Cache/AspMemoryCache.cs
@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
+
using Microsoft.Extensions.Caching.Memory;
public class AspMemoryCache : IOcelotCache
@@ -28,7 +29,7 @@ public void Add(string key, T value, TimeSpan ttl, string region)
}
public T Get(string key, string region)
- {
+ {
if (_memoryCache.TryGetValue(key, out T value))
{
return value;
@@ -51,7 +52,7 @@ public void ClearRegion(string region)
public void AddAndDelete(string key, T value, TimeSpan ttl, string region)
{
- if (_memoryCache.TryGetValue(key, out T oldValue))
+ if (_memoryCache.TryGetValue(key, out T _))
{
_memoryCache.Remove(key);
}
diff --git a/src/Ocelot/Cache/CacheKeyGenerator.cs b/src/Ocelot/Cache/CacheKeyGenerator.cs
index 2c1f44d0d..ee1497118 100644
--- a/src/Ocelot/Cache/CacheKeyGenerator.cs
+++ b/src/Ocelot/Cache/CacheKeyGenerator.cs
@@ -1,22 +1,22 @@
namespace Ocelot.Cache
{
- using Ocelot.Request.Middleware;
using System.Text;
using System.Threading.Tasks;
+ using Ocelot.Request.Middleware;
+
public class CacheKeyGenerator : ICacheKeyGenerator
{
public string GenerateRequestCacheKey(DownstreamRequest downstreamRequest)
{
- string hashedContent = null;
- StringBuilder downStreamUrlKeyBuilder = new StringBuilder($"{downstreamRequest.Method}-{downstreamRequest.OriginalString}");
+ var downStreamUrlKeyBuilder = new StringBuilder($"{downstreamRequest.Method}-{downstreamRequest.OriginalString}");
if (downstreamRequest.Content != null)
{
- string requestContentString = Task.Run(async () => await downstreamRequest.Content.ReadAsStringAsync()).Result;
+ var requestContentString = Task.Run(async () => await downstreamRequest.Content.ReadAsStringAsync()).Result;
downStreamUrlKeyBuilder.Append(requestContentString);
}
- hashedContent = MD5Helper.GenerateMd5(downStreamUrlKeyBuilder.ToString());
+ var hashedContent = MD5Helper.GenerateMd5(downStreamUrlKeyBuilder.ToString());
return hashedContent;
}
}
diff --git a/src/Ocelot/Cache/CachedResponse.cs b/src/Ocelot/Cache/CachedResponse.cs
index aa2fafcc6..b0806252c 100644
--- a/src/Ocelot/Cache/CachedResponse.cs
+++ b/src/Ocelot/Cache/CachedResponse.cs
@@ -16,18 +16,18 @@ string reasonPhrase
StatusCode = statusCode;
Headers = headers ?? new Dictionary>();
ContentHeaders = contentHeaders ?? new Dictionary>();
- Body = body ?? "";
+ Body = body ?? string.Empty;
ReasonPhrase = reasonPhrase;
}
- public HttpStatusCode StatusCode { get; private set; }
+ public HttpStatusCode StatusCode { get; }
- public Dictionary> Headers { get; private set; }
+ public Dictionary> Headers { get; }
- public Dictionary> ContentHeaders { get; private set; }
+ public Dictionary> ContentHeaders { get; }
- public string Body { get; private set; }
+ public string Body { get; }
- public string ReasonPhrase { get; private set; }
+ public string ReasonPhrase { get; }
}
}
diff --git a/src/Ocelot/Cache/MD5Helper.cs b/src/Ocelot/Cache/MD5Helper.cs
index ff8eaa30b..c268fb021 100644
--- a/src/Ocelot/Cache/MD5Helper.cs
+++ b/src/Ocelot/Cache/MD5Helper.cs
@@ -7,10 +7,10 @@ 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++)
+ var md5 = MD5.Create();
+ var hash = md5.ComputeHash(contentBytes);
+ var sb = new StringBuilder();
+ for (var i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
@@ -20,7 +20,7 @@ public static string GenerateMd5(byte[] contentBytes)
public static string GenerateMd5(string contentString)
{
- byte[] contentBytes = Encoding.Unicode.GetBytes(contentString);
+ var 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 ea544d2b5..a155993dd 100644
--- a/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs
+++ b/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs
@@ -1,14 +1,15 @@
namespace Ocelot.Cache.Middleware
{
- using Ocelot.Logging;
- using Ocelot.Middleware;
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
+
using Microsoft.AspNetCore.Http;
- using Ocelot.DownstreamRouteFinder.Middleware;
+
+ using Logging;
+ using Ocelot.Middleware;
public class OutputCacheMiddleware : OcelotMiddleware
{
@@ -40,7 +41,7 @@ public async Task Invoke(HttpContext httpContext)
var downstreamRequest = httpContext.Items.DownstreamRequest();
var downstreamUrlKey = $"{downstreamRequest.Method}-{downstreamRequest.OriginalString}";
- string downStreamRequestCacheKey = _cacheGenerator.GenerateRequestCacheKey(downstreamRequest);
+ var downStreamRequestCacheKey = _cacheGenerator.GenerateRequestCacheKey(downstreamRequest);
Logger.LogDebug($"Started checking cache for {downstreamUrlKey}");
@@ -78,7 +79,7 @@ public async Task Invoke(HttpContext httpContext)
Logger.LogDebug($"finished response added to cache for {downstreamUrlKey}");
}
- private void SetHttpResponseMessageThisRequest(HttpContext context,
+ private static void SetHttpResponseMessageThisRequest(HttpContext context,
DownstreamResponse response)
{
context.Items.UpsertDownstreamResponse(response);
diff --git a/src/Ocelot/Cache/RegionCreator.cs b/src/Ocelot/Cache/RegionCreator.cs
index 050d6f2f2..737d886e5 100644
--- a/src/Ocelot/Cache/RegionCreator.cs
+++ b/src/Ocelot/Cache/RegionCreator.cs
@@ -1,5 +1,6 @@
-using Ocelot.Configuration.File;
using System.Linq;
+
+using Ocelot.Configuration.File;
namespace Ocelot.Cache
{
@@ -12,9 +13,9 @@ public string Create(FileRoute route)
return route?.FileCacheOptions?.Region;
}
- var methods = string.Join("", route.UpstreamHttpMethod.Select(m => m));
+ var methods = string.Join(string.Empty, route.UpstreamHttpMethod.Select(m => m));
- var region = $"{methods}{route.UpstreamPathTemplate.Replace("/", "")}";
+ var region = $"{methods}{route.UpstreamPathTemplate.Replace("/", string.Empty)}";
return region;
}
diff --git a/src/Ocelot/Claims/AddClaimsToRequest.cs b/src/Ocelot/Claims/AddClaimsToRequest.cs
index ab197c2b0..56e9f2824 100644
--- a/src/Ocelot/Claims/AddClaimsToRequest.cs
+++ b/src/Ocelot/Claims/AddClaimsToRequest.cs
@@ -1,10 +1,12 @@
-using Microsoft.AspNetCore.Http;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+
+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
{
@@ -37,7 +39,7 @@ public Response SetClaimsOnContext(List claimsToThings, HttpContex
identity?.RemoveClaim(exists);
}
- identity?.AddClaim(new System.Security.Claims.Claim(config.ExistingKey, value.Data));
+ identity?.AddClaim(new Claim(config.ExistingKey, value.Data));
}
return new OkResponse();
diff --git a/src/Ocelot/Claims/IAddClaimsToRequest.cs b/src/Ocelot/Claims/IAddClaimsToRequest.cs
index b9db39f5b..902df93af 100644
--- a/src/Ocelot/Claims/IAddClaimsToRequest.cs
+++ b/src/Ocelot/Claims/IAddClaimsToRequest.cs
@@ -1,7 +1,9 @@
-using Microsoft.AspNetCore.Http;
+using System.Collections.Generic;
+
+using Microsoft.AspNetCore.Http;
+
using Ocelot.Configuration;
-using Ocelot.Responses;
-using System.Collections.Generic;
+using Ocelot.Responses;
namespace Ocelot.Claims
{
diff --git a/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs b/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
index 780736b21..153091154 100644
--- a/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
+++ b/src/Ocelot/Claims/Middleware/ClaimsToClaimsMiddleware.cs
@@ -1,11 +1,12 @@
namespace Ocelot.Claims.Middleware
{
- using Microsoft.AspNetCore.Http;
- using Ocelot.DownstreamRouteFinder.Middleware;
- using Ocelot.Logging;
- using Ocelot.Middleware;
using System.Linq;
using System.Threading.Tasks;
+
+ using Microsoft.AspNetCore.Http;
+
+ using Logging;
+ using Ocelot.Middleware;
public class ClaimsToClaimsMiddleware : OcelotMiddleware
{
diff --git a/src/Ocelot/Configuration/AuthenticationOptions.cs b/src/Ocelot/Configuration/AuthenticationOptions.cs
index 9cede7954..d9a912b53 100644
--- a/src/Ocelot/Configuration/AuthenticationOptions.cs
+++ b/src/Ocelot/Configuration/AuthenticationOptions.cs
@@ -10,7 +10,7 @@ public AuthenticationOptions(List allowedScopes, string authenticationPr
AuthenticationProviderKey = authenticationProviderKey;
}
- public List AllowedScopes { get; private set; }
- public string AuthenticationProviderKey { get; private set; }
+ public List AllowedScopes { get; }
+ public string AuthenticationProviderKey { get; }
}
}
diff --git a/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs b/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs
index 352bc8a6b..65408e3a4 100644
--- a/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/AuthenticationOptionsBuilder.cs
@@ -4,7 +4,7 @@ namespace Ocelot.Configuration.Builder
{
public class AuthenticationOptionsBuilder
{
- private List _allowedScopes = new List();
+ private List _allowedScopes = new();
private string _authenticationProviderKey;
public AuthenticationOptionsBuilder WithAllowedScopes(List allowedScopes)
@@ -24,4 +24,4 @@ public AuthenticationOptions Build()
return new AuthenticationOptions(_allowedScopes, _authenticationProviderKey);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
index 5ee5ddf73..5ed5e704b 100644
--- a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs
@@ -1,9 +1,10 @@
-using Ocelot.Configuration.Creator;
-using Ocelot.Values;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
+
+using Ocelot.Configuration.Creator;
+using Ocelot.Values;
namespace Ocelot.Configuration.Builder
{
diff --git a/src/Ocelot/Configuration/Builder/RouteBuilder.cs b/src/Ocelot/Configuration/Builder/RouteBuilder.cs
index 1194b5ea7..e7ba3ec45 100644
--- a/src/Ocelot/Configuration/Builder/RouteBuilder.cs
+++ b/src/Ocelot/Configuration/Builder/RouteBuilder.cs
@@ -1,10 +1,11 @@
namespace Ocelot.Configuration.Builder
{
- using Ocelot.Configuration.File;
- using Ocelot.Values;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
+
+ using File;
+ using Values;
public class RouteBuilder
{
diff --git a/src/Ocelot/Configuration/CacheOptions.cs b/src/Ocelot/Configuration/CacheOptions.cs
index e5738a46e..d509b38e9 100644
--- a/src/Ocelot/Configuration/CacheOptions.cs
+++ b/src/Ocelot/Configuration/CacheOptions.cs
@@ -8,8 +8,8 @@ public CacheOptions(int ttlSeconds, string region)
Region = region;
}
- public int TtlSeconds { get; private set; }
+ public int TtlSeconds { get; }
- public string Region { get; private set; }
+ public string Region { get; }
}
}
diff --git a/src/Ocelot/Configuration/ChangeTracking/OcelotConfigurationChangeToken.cs b/src/Ocelot/Configuration/ChangeTracking/OcelotConfigurationChangeToken.cs
index ecefcf9b1..a7df47748 100644
--- a/src/Ocelot/Configuration/ChangeTracking/OcelotConfigurationChangeToken.cs
+++ b/src/Ocelot/Configuration/ChangeTracking/OcelotConfigurationChangeToken.cs
@@ -2,6 +2,7 @@ namespace Ocelot.Configuration.ChangeTracking
{
using System;
using System.Collections.Generic;
+
using Microsoft.Extensions.Primitives;
public class OcelotConfigurationChangeToken : IChangeToken
@@ -9,7 +10,7 @@ public class OcelotConfigurationChangeToken : IChangeToken
public const double PollingIntervalSeconds = 1;
private readonly ICollection _callbacks = new List();
- private readonly object _lock = new object();
+ private readonly object _lock = new();
private DateTime? _timeChanged;
public IDisposable RegisterChangeCallback(Action