mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
Reducing Warnings from Ocelot (#743)
This commit is contained in:
parent
6495891a07
commit
02e5cea7b1
@ -1,9 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Ocelot.Middleware.Pipeline;
|
||||||
using Ocelot.Middleware.Pipeline;
|
|
||||||
|
|
||||||
namespace Ocelot.Claims.Middleware
|
namespace Ocelot.Claims.Middleware
|
||||||
{
|
{
|
||||||
public static class ClaimsToClaimsMiddlewareExtensions
|
public static class ClaimsBuilderMiddlewareExtensions
|
||||||
{
|
{
|
||||||
public static IOcelotPipelineBuilder UseClaimsToClaimsMiddleware(this IOcelotPipelineBuilder builder)
|
public static IOcelotPipelineBuilder UseClaimsToClaimsMiddleware(this IOcelotPipelineBuilder builder)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@ using Ocelot.Configuration.File;
|
|||||||
|
|
||||||
namespace Ocelot.Configuration.Creator
|
namespace Ocelot.Configuration.Creator
|
||||||
{
|
{
|
||||||
|
|
||||||
public class LoadBalancerOptionsCreator : ILoadBalancerOptionsCreator
|
public class LoadBalancerOptionsCreator : ILoadBalancerOptionsCreator
|
||||||
{
|
{
|
||||||
public LoadBalancerOptions Create(FileLoadBalancerOptions options)
|
public LoadBalancerOptions Create(FileLoadBalancerOptions options)
|
||||||
|
@ -26,7 +26,6 @@ namespace Ocelot.Infrastructure
|
|||||||
{ "{BaseUrl}", GetBaseUrl() },
|
{ "{BaseUrl}", GetBaseUrl() },
|
||||||
{ "{TraceId}", GetTraceId() },
|
{ "{TraceId}", GetTraceId() },
|
||||||
{ "{RemoteIpAddress}", GetRemoteIpAddress() }
|
{ "{RemoteIpAddress}", GetRemoteIpAddress() }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_requestPlaceholders = new Dictionary<string, Func<DownstreamRequest, string>>
|
_requestPlaceholders = new Dictionary<string, Func<DownstreamRequest, string>>
|
||||||
@ -91,7 +90,7 @@ namespace Ocelot.Infrastructure
|
|||||||
var remoteIdAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
var remoteIdAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||||
return new OkResponse<string>(remoteIdAddress);
|
return new OkResponse<string>(remoteIdAddress);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch
|
||||||
{
|
{
|
||||||
return new ErrorResponse<string>(new CouldNotFindPlaceholderError("{RemoteIpAddress}"));
|
return new ErrorResponse<string>(new CouldNotFindPlaceholderError("{RemoteIpAddress}"));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using Ocelot.Configuration;
|
||||||
|
using Ocelot.Responses;
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ocelot.Configuration;
|
|
||||||
using Ocelot.Responses;
|
|
||||||
|
|
||||||
namespace Ocelot.LoadBalancer.LoadBalancers
|
namespace Ocelot.LoadBalancer.LoadBalancers
|
||||||
{
|
{
|
||||||
@ -35,6 +35,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
{
|
{
|
||||||
return new ErrorResponse<ILoadBalancer>(result.Errors);
|
return new ErrorResponse<ILoadBalancer>(result.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancer = result.Data;
|
loadBalancer = result.Data;
|
||||||
AddLoadBalancer(reRoute.LoadBalancerKey, loadBalancer);
|
AddLoadBalancer(reRoute.LoadBalancerKey, loadBalancer);
|
||||||
}
|
}
|
||||||
@ -43,10 +44,12 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = await _factory.Get(reRoute, config);
|
result = await _factory.Get(reRoute, config);
|
||||||
|
|
||||||
if (result.IsError)
|
if (result.IsError)
|
||||||
{
|
{
|
||||||
return new ErrorResponse<ILoadBalancer>(result.Errors);
|
return new ErrorResponse<ILoadBalancer>(result.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBalancer = result.Data;
|
loadBalancer = result.Data;
|
||||||
AddLoadBalancer(reRoute.LoadBalancerKey, loadBalancer);
|
AddLoadBalancer(reRoute.LoadBalancerKey, loadBalancer);
|
||||||
return new OkResponse<ILoadBalancer>(loadBalancer);
|
return new OkResponse<ILoadBalancer>(loadBalancer);
|
||||||
|
@ -15,7 +15,6 @@ namespace Ocelot.Logging
|
|||||||
{
|
{
|
||||||
_logger = factory.CreateLogger<OcelotDiagnosticListener>();
|
_logger = factory.CreateLogger<OcelotDiagnosticListener>();
|
||||||
_tracer = serviceProvider.GetService<ITracer>();
|
_tracer = serviceProvider.GetService<ITracer>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DiagnosticName("Ocelot.MiddlewareException")]
|
[DiagnosticName("Ocelot.MiddlewareException")]
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
// now create the config
|
// now create the config
|
||||||
var internalConfigCreator = builder.ApplicationServices.GetService<IInternalConfigurationCreator>();
|
var internalConfigCreator = builder.ApplicationServices.GetService<IInternalConfigurationCreator>();
|
||||||
var internalConfig = await internalConfigCreator.Create(fileConfig.CurrentValue);
|
var internalConfig = await internalConfigCreator.Create(fileConfig.CurrentValue);
|
||||||
|
|
||||||
//Configuration error, throw error message
|
//Configuration error, throw error message
|
||||||
if (internalConfig.IsError)
|
if (internalConfig.IsError)
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
/// This allows the user to implement there own query string manipulation logic
|
/// This allows the user to implement there own query string manipulation logic
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<DownstreamContext, Func<Task>, Task> PreQueryStringBuilderMiddleware { get; set; }
|
public Func<DownstreamContext, Func<Task>, Task> PreQueryStringBuilderMiddleware { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is an extension that will branch to different pipes
|
/// This is an extension that will branch to different pipes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,14 +2,13 @@
|
|||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
// Removed code and changed RequestDelete to OcelotRequestDelete, HttpContext to DownstreamContext, removed some exception handling messages
|
// Removed code and changed RequestDelete to OcelotRequestDelete, HttpContext to DownstreamContext, removed some exception handling messages
|
||||||
|
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Ocelot.Middleware.Pipeline
|
namespace Ocelot.Middleware.Pipeline
|
||||||
{
|
{
|
||||||
@ -167,10 +166,12 @@ namespace Ocelot.Middleware.Pipeline
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(app));
|
throw new ArgumentNullException(nameof(app));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pipelineBuilderFunc == null)
|
if (pipelineBuilderFunc == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(pipelineBuilderFunc));
|
throw new ArgumentNullException(nameof(pipelineBuilderFunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
var branchBuilder = app.New();
|
var branchBuilder = app.New();
|
||||||
var predicate = pipelineBuilderFunc.Invoke(branchBuilder);
|
var predicate = pipelineBuilderFunc.Invoke(branchBuilder);
|
||||||
var branch = branchBuilder.Build();
|
var branch = branchBuilder.Build();
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
HttpRequestMessage request,
|
HttpRequestMessage request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
||||||
return _tracer.SendAsync(request, cancellationToken, x => _repo.Add("TraceId", x), (r, c) => base.SendAsync(r, c));
|
return _tracer.SendAsync(request, cancellationToken, x => _repo.Add("TraceId", x), (r, c) => base.SendAsync(r, c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user