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