mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-23 00:32:50 +08:00
Fix single-line comment spacing
SA1512, SA1515
This commit is contained in:
parent
f24c0a0510
commit
b18c8e5f2b
@ -12,6 +12,7 @@ namespace Ocelot.Configuration.File
|
||||
}
|
||||
|
||||
public List<FileReRoute> ReRoutes { get; set; }
|
||||
|
||||
// Seperate field for aggregates because this let's you re-use ReRoutes in multiple Aggregates
|
||||
public List<FileAggregateReRoute> Aggregates { get;set; }
|
||||
public FileGlobalConfiguration GlobalConfiguration { get; set; }
|
||||
|
@ -26,6 +26,7 @@ namespace Ocelot.Configuration.File
|
||||
public string Period { get; set; }
|
||||
|
||||
public double PeriodTimespan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of requests that a client can make in a defined period
|
||||
/// </summary>
|
||||
|
@ -17,6 +17,7 @@ namespace Ocelot.Configuration
|
||||
public string Period { get; private set; }
|
||||
|
||||
public double PeriodTimespan { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of requests that a client can make in a defined period
|
||||
/// </summary>
|
||||
|
@ -59,8 +59,8 @@ namespace Ocelot.DownstreamRouteFinder.Middleware
|
||||
return;
|
||||
}
|
||||
|
||||
//todo - put this back in
|
||||
// _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamReRoute.DownstreamPathTemplate);
|
||||
// todo - put this back in
|
||||
//// _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamReRoute.DownstreamPathTemplate);
|
||||
|
||||
context.TemplatePlaceholderNameAndValues = downstreamRoute.Data.TemplatePlaceholderNameAndValues;
|
||||
|
||||
|
@ -22,8 +22,6 @@ namespace Ocelot.Middleware
|
||||
public HttpRequestMessage DownstreamRequest { get; set; }
|
||||
public HttpResponseMessage DownstreamResponse { get; set; }
|
||||
public List<Error> Errors { get;set; }
|
||||
//public string RequestId {get;set;}
|
||||
//public string PreviousRequestId {get;set;}
|
||||
public bool IsError => Errors.Count > 0;
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,11 @@
|
||||
|
||||
var firstDelegate = pipelineBuilder.Build();
|
||||
|
||||
//inject first delegate into first piece of asp.net middleware..maybe not like this
|
||||
//then because we are updating the http context in ocelot it comes out correct for
|
||||
//rest of asp.net..
|
||||
/*
|
||||
inject first delegate into first piece of asp.net middleware..maybe not like this
|
||||
then because we are updating the http context in ocelot it comes out correct for
|
||||
rest of asp.net..
|
||||
*/
|
||||
|
||||
builder.Use(async (context, task) =>
|
||||
{
|
||||
|
@ -27,11 +27,13 @@ namespace Ocelot.Raft
|
||||
_finder = finder;
|
||||
_options = options;
|
||||
_peers = new List<IPeer>();
|
||||
|
||||
//todo - sort out async nonsense..
|
||||
var config = _provider.Get().GetAwaiter().GetResult();
|
||||
foreach (var item in _options.Value.Peers)
|
||||
{
|
||||
var httpClient = new HttpClient();
|
||||
|
||||
//todo what if this errors?
|
||||
var httpPeer = new HttpPeer(item.HostAndPort, httpClient, _finder, config.Data, _identityServerConfig);
|
||||
_peers.Add(httpPeer);
|
||||
|
@ -133,6 +133,7 @@ namespace Ocelot.Raft
|
||||
TypeNameHandling = TypeNameHandling.All
|
||||
};
|
||||
var data = JsonConvert.SerializeObject(log, jsonSerializerSettings);
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var sql = $"insert into logs (data) values ('{data}')";
|
||||
using(var command = new SqliteCommand(sql, connection))
|
||||
@ -157,6 +158,7 @@ namespace Ocelot.Raft
|
||||
using(var connection = new SqliteConnection($"Data Source={_path};"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var sql = $"select data from logs where id = {index};";
|
||||
using(var command = new SqliteCommand(sql, connection))
|
||||
@ -187,6 +189,7 @@ namespace Ocelot.Raft
|
||||
using(var connection = new SqliteConnection($"Data Source={_path};"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var sql = $"select data from logs where id = {index}";
|
||||
using(var command = new SqliteCommand(sql, connection))
|
||||
@ -211,6 +214,7 @@ namespace Ocelot.Raft
|
||||
using(var connection = new SqliteConnection($"Data Source={_path};"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var sql = $"select id, data from logs where id >= {index}";
|
||||
using(var command = new SqliteCommand(sql, connection))
|
||||
@ -243,6 +247,7 @@ namespace Ocelot.Raft
|
||||
using(var connection = new SqliteConnection($"Data Source={_path};"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var sql = $"select data from logs where id = {index}";
|
||||
using(var command = new SqliteCommand(sql, connection))
|
||||
@ -270,6 +275,7 @@ namespace Ocelot.Raft
|
||||
using(var connection = new SqliteConnection($"Data Source={_path};"))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
//todo - sql injection dont copy this..
|
||||
var deleteSql = $"delete from logs where id >= {indexOfCommand};";
|
||||
using(var deleteCommand = new SqliteCommand(deleteSql, connection))
|
||||
|
@ -31,6 +31,7 @@ namespace Ocelot.RateLimit.Middleware
|
||||
public async Task Invoke(DownstreamContext context)
|
||||
{
|
||||
var options = context.DownstreamReRoute.RateLimitOptions;
|
||||
|
||||
// check if rate limiting is enabled
|
||||
if (!context.DownstreamReRoute.EnableEndpointEndpointRateLimiting)
|
||||
{
|
||||
@ -66,6 +67,7 @@ namespace Ocelot.RateLimit.Middleware
|
||||
LogBlockedRequest(context.HttpContext, identity, counter, rule, context.DownstreamReRoute);
|
||||
|
||||
var retrystring = retryAfter.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
// break execution
|
||||
await ReturnQuotaExceededResponse(context.HttpContext, options, retrystring);
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace Ocelot.RateLimit
|
||||
{
|
||||
// increment request count
|
||||
var totalRequests = entry.Value.TotalRequests + 1;
|
||||
|
||||
// deep copy
|
||||
counter = new RateLimitCounter(entry.Value.Timestamp, totalRequests);
|
||||
}
|
||||
@ -70,6 +71,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);
|
||||
}
|
||||
|
@ -21,8 +21,10 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
_httpDataRepository = new HttpDataRepository(_httpContextAccessor);
|
||||
}
|
||||
|
||||
//TODO - Additional tests -> Type mistmatch aka Add string, request int
|
||||
//TODO - Additional tests -> HttpContent null. This should never happen
|
||||
/*
|
||||
TODO - Additional tests -> Type mistmatch aka Add string, request int
|
||||
TODO - Additional tests -> HttpContent null. This should never happen
|
||||
*/
|
||||
|
||||
[Fact]
|
||||
public void get_returns_correct_key_from_http_context()
|
||||
|
Loading…
x
Reference in New Issue
Block a user