mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 17:48:15 +08:00
update .net core 3.0 RTM (#1025)
* feat: update to asp.net core 3.0 preview 9 * fix : AspDotNetLogger unittest * feat: update generic host and useMvc 1、Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing https://github.com/aspnet/AspNetCore/issues/9542 2、 use IHost and IHostBuilder * feat : update .net core 3.0 rc1 * eureka extension * fixed logger formatter error * fixed synchronous operations are disallowed of ReadToEnd method * fix log tests * Flush method of FakeStream should do nothing * Update ContentTests.cs * Fixed ws tests * feat: delelte comment code * feat: update .net core 3.0 RTM * Update OcelotBuilderTests.cs * Update .travis.yml mono 6.0.0 and dotnet 3.0.100 * Update Ocelot.IntegrationTests.csproj update Microsoft.Data.SQLite 3.0.0 * Update .travis.yml * feat: remove FrameworkReference 1、 remove FrameworkReference 2、 update package * add appveyor configuration to use version of VS2019 with dotnet core 3 sdk support * update obsoleted SetCollectionValidator method * Swap out OpenCover for Coverlet * Bump Cake to 0.35.0 * Downgrade coveralls.net to 0.7.0 Fix disposing of PollConsul instance * Remove environment specific path separator * Do not return ReportGenerator on Mac/Linux * Remove direct dependency on IInternalConfiguration * Fix ordering of variable assignment * Fix broken tests * Fix acceptance tests for Consul
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use the administration API and IdentityService dependencies that come with it</Description>
|
||||
<AssemblyTitle>Ocelot.Administration</AssemblyTitle>
|
||||
@ -29,10 +27,13 @@
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
|
||||
<PackageReference Include="IdentityServer4" Version="2.4.0" />
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
||||
<PackageReference Include="IdentityServer4" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,18 +1,18 @@
|
||||
namespace Ocelot.Administration
|
||||
{
|
||||
using DependencyInjection;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Models;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
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 Ocelot.DependencyInjection;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Models;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
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;
|
||||
|
||||
namespace Ocelot.Administration
|
||||
{
|
||||
public static class OcelotBuilderExtensions
|
||||
{
|
||||
public static IOcelotAdministrationBuilder AddAdministration(this IOcelotBuilder builder, string path, string secret)
|
||||
@ -86,7 +86,7 @@
|
||||
else
|
||||
{
|
||||
//todo - refactor so calls method?
|
||||
var cert = new X509Certificate2(identityServerConfiguration.CredentialsSigningCertificateLocation, identityServerConfiguration.CredentialsSigningCertificatePassword);
|
||||
var cert = new X509Certificate2(identityServerConfiguration.CredentialsSigningCertificateLocation, identityServerConfiguration.CredentialsSigningCertificatePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
|
||||
identityServerBuilder.AddSigningCredential(cert);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use CacheManager.Net</Description>
|
||||
<AssemblyTitle>Ocelot.Cache.CacheManager</AssemblyTitle>
|
||||
@ -28,11 +26,14 @@
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CacheManager.Core" Version="1.2.0" />
|
||||
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="1.2.0" />
|
||||
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.2.0" />
|
||||
<PackageReference Include="CacheManager.Core" Version="2.0.0-beta-1629" />
|
||||
<PackageReference Include="CacheManager.Microsoft.Extensions.Configuration" Version="2.0.0-beta-1629" />
|
||||
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="2.0.0-beta-1629" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -4,6 +4,7 @@
|
||||
using Configuration.Repository;
|
||||
using global::Consul;
|
||||
using Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Responses;
|
||||
using System;
|
||||
@ -18,29 +19,20 @@
|
||||
private readonly IOcelotLogger _logger;
|
||||
|
||||
public ConsulFileConfigurationRepository(
|
||||
IOptions<FileConfiguration> fileConfiguration,
|
||||
Cache.IOcelotCache<FileConfiguration> cache,
|
||||
IInternalConfigurationRepository repo,
|
||||
IConsulClientFactory factory,
|
||||
IOcelotLoggerFactory loggerFactory)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<ConsulFileConfigurationRepository>();
|
||||
_cache = cache;
|
||||
|
||||
var internalConfig = repo.Get();
|
||||
var serviceDiscoveryProvider = fileConfiguration.Value.GlobalConfiguration.ServiceDiscoveryProvider;
|
||||
_configurationKey = string.IsNullOrWhiteSpace(serviceDiscoveryProvider.ConfigurationKey) ? "InternalConfiguration" :
|
||||
serviceDiscoveryProvider.ConfigurationKey;
|
||||
|
||||
_configurationKey = "InternalConfiguration";
|
||||
|
||||
string token = null;
|
||||
|
||||
if (!internalConfig.IsError)
|
||||
{
|
||||
token = internalConfig.Data.ServiceProviderConfiguration.Token;
|
||||
_configurationKey = !string.IsNullOrEmpty(internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey) ?
|
||||
internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey : _configurationKey;
|
||||
}
|
||||
|
||||
var config = new ConsulRegistryConfiguration(internalConfig.Data.ServiceProviderConfiguration.Host,
|
||||
internalConfig.Data.ServiceProviderConfiguration.Port, _configurationKey, token);
|
||||
var config = new ConsulRegistryConfiguration(serviceDiscoveryProvider.Host,
|
||||
serviceDiscoveryProvider.Port, _configurationKey, serviceDiscoveryProvider.Token);
|
||||
|
||||
_consul = factory.Get(config);
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use Consul</Description>
|
||||
<AssemblyTitle>Ocelot.Provider.Consul</AssemblyTitle>
|
||||
@ -30,8 +28,11 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Consul" Version="0.7.2.6" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -2,16 +2,17 @@
|
||||
{
|
||||
using Logging;
|
||||
using ServiceDiscovery.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Values;
|
||||
|
||||
public class PollConsul : IServiceDiscoveryProvider
|
||||
public sealed class PollConsul : IServiceDiscoveryProvider, IDisposable
|
||||
{
|
||||
private readonly IOcelotLogger _logger;
|
||||
private readonly IServiceDiscoveryProvider _consulServiceDiscoveryProvider;
|
||||
private readonly Timer _timer;
|
||||
private Timer _timer;
|
||||
private bool _polling;
|
||||
private List<Service> _services;
|
||||
|
||||
@ -34,6 +35,12 @@
|
||||
}, null, pollingInterval, pollingInterval);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_timer?.Dispose();
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
public Task<List<Service>> Get()
|
||||
{
|
||||
return Task.FromResult(_services);
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use Eureka</Description>
|
||||
<AssemblyTitle>Ocelot.Provider.Eureka</AssemblyTitle>
|
||||
@ -29,9 +27,12 @@
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="2.2.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="2.3.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -12,9 +12,7 @@
|
||||
{
|
||||
public static IOcelotBuilder AddEureka(this IOcelotBuilder builder)
|
||||
{
|
||||
var service = builder.Services.First(x => x.ServiceType == typeof(IConfiguration));
|
||||
var configuration = (IConfiguration)service.ImplementationInstance;
|
||||
builder.Services.AddDiscoveryClient(configuration);
|
||||
builder.Services.AddDiscoveryClient(builder.Configuration);
|
||||
builder.Services.AddSingleton<ServiceDiscoveryFinderDelegate>(EurekaProviderFactory.Get);
|
||||
builder.Services.AddSingleton<OcelotMiddlewareConfigurationDelegate>(EurekaMiddlewareConfigurationProvider.Get);
|
||||
return builder;
|
||||
|
@ -1,9 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Product>Ocelot</Product>
|
||||
<Description>Provides Ocelot extensions to use kubernetes</Description>
|
||||
@ -30,12 +28,16 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="KubeClient" Version="2.2.12" />
|
||||
<PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.2.12" />
|
||||
<PackageReference Include="KubeClient" Version="2.3.4" />
|
||||
<PackageReference Include="KubeClient.Extensions.DependencyInjection" Version="2.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use Polly.NET</Description>
|
||||
<AssemblyTitle>Ocelot.Provider.Polly</AssemblyTitle>
|
||||
@ -29,9 +27,12 @@
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Polly" Version="7.1.0" />
|
||||
<PackageReference Include="Polly" Version="7.1.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Provides Ocelot extensions to use Rafty</Description>
|
||||
<AssemblyTitle>Ocelot.Provider.Rafty</AssemblyTitle>
|
||||
@ -30,10 +28,13 @@
|
||||
<ProjectReference Include="..\Ocelot.Administration\Ocelot.Administration.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SQLite" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.Data.SQLite" Version="3.0.0" />
|
||||
<PackageReference Include="Rafty" Version="0.4.4" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,9 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>This package provides methods to integrate Butterfly tracing with Ocelot.</Description>
|
||||
<AssemblyTitle>Ocelot.Tracing.Butterfly</AssemblyTitle>
|
||||
@ -33,5 +31,8 @@
|
||||
<PackageReference Include="Butterfly.Client" Version="0.0.8" />
|
||||
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -14,7 +14,7 @@ namespace Ocelot.Configuration.Repository
|
||||
private static readonly object _lock = new object();
|
||||
private const string ConfigurationFileName = "ocelot";
|
||||
|
||||
public DiskFileConfigurationRepository(IHostingEnvironment hostingEnvironment)
|
||||
public DiskFileConfigurationRepository(IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
_environmentFilePath = $"{AppContext.BaseDirectory}{ConfigurationFileName}{(string.IsNullOrEmpty(hostingEnvironment.EnvironmentName) ? string.Empty : ".")}{hostingEnvironment.EnvironmentName}.json";
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
.GetServices<ServiceDiscoveryFinderDelegate>()
|
||||
.ToList();
|
||||
|
||||
RuleFor(configuration => configuration.ReRoutes)
|
||||
.SetCollectionValidator(reRouteFluentValidator);
|
||||
RuleForEach(configuration => configuration.ReRoutes)
|
||||
.SetValidator(reRouteFluentValidator);
|
||||
|
||||
RuleFor(configuration => configuration.GlobalConfiguration)
|
||||
.SetValidator(fileGlobalConfigurationFluentValidator);
|
||||
|
@ -80,8 +80,8 @@
|
||||
|
||||
When(reRoute => string.IsNullOrEmpty(reRoute.ServiceName), () =>
|
||||
{
|
||||
RuleFor(reRoute => reRoute.DownstreamHostAndPorts)
|
||||
.SetCollectionValidator(hostAndPortValidator);
|
||||
RuleForEach(reRoute => reRoute.DownstreamHostAndPorts)
|
||||
.SetValidator(hostAndPortValidator);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -29,12 +29,12 @@ namespace Ocelot.DependencyInjection
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, IHostingEnvironment env)
|
||||
public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, IWebHostEnvironment env)
|
||||
{
|
||||
return builder.AddOcelot(".", env);
|
||||
}
|
||||
|
||||
public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, string folder, IHostingEnvironment env)
|
||||
public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder, string folder, IWebHostEnvironment env)
|
||||
{
|
||||
const string primaryConfigFile = "ocelot.json";
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace Ocelot.DependencyInjection
|
||||
.AddApplicationPart(assembly)
|
||||
.AddControllersAsServices()
|
||||
.AddAuthorization()
|
||||
.AddJsonFormatters();
|
||||
.AddNewtonsoftJson();
|
||||
|
||||
Services.AddLogging();
|
||||
Services.AddMiddlewareAnalysis();
|
||||
|
@ -7,9 +7,9 @@ namespace Ocelot.DependencyInjection
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IOcelotBuilder AddOcelot(this IServiceCollection services)
|
||||
{
|
||||
var service = services.First(x => x.ServiceType == typeof(IConfiguration));
|
||||
var configuration = (IConfiguration)service.ImplementationInstance;
|
||||
{
|
||||
var configuration = services.BuildServiceProvider()
|
||||
.GetRequiredService<IConfiguration>();
|
||||
return new OcelotBuilder(services, configuration);
|
||||
}
|
||||
|
||||
|
@ -8,53 +8,83 @@ namespace Ocelot.Logging
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRequestScopedDataRepository _scopedDataRepository;
|
||||
private readonly Func<string, Exception, string> _func;
|
||||
|
||||
public AspDotNetLogger(ILogger logger, IRequestScopedDataRepository scopedDataRepository)
|
||||
{
|
||||
_logger = logger;
|
||||
_scopedDataRepository = scopedDataRepository;
|
||||
_scopedDataRepository = scopedDataRepository;
|
||||
_func = (state, exception) =>
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{state}, exception: {exception}";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void LogTrace(string message)
|
||||
{
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogTrace("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Trace, default(EventId), state, null, _func);
|
||||
}
|
||||
|
||||
public void LogDebug(string message)
|
||||
{
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogDebug("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Debug, default(EventId), state, null, _func);
|
||||
}
|
||||
|
||||
public void LogInformation(string message)
|
||||
{
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogInformation("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Information, default(EventId), state, null, _func);
|
||||
}
|
||||
|
||||
public void LogWarning(string message)
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogWarning("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}", requestId, previousRequestId, message);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Warning, default(EventId), state, null, _func);
|
||||
}
|
||||
|
||||
public void LogError(string message, Exception exception)
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogError("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}, exception: {exception}", requestId, previousRequestId, message, exception);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Error,default(EventId), state, exception, _func);
|
||||
}
|
||||
|
||||
public void LogCritical(string message, Exception exception)
|
||||
{
|
||||
var requestId = GetOcelotRequestId();
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
_logger.LogCritical("requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}, exception: {exception}", requestId, previousRequestId, message, exception);
|
||||
var previousRequestId = GetOcelotPreviousRequestId();
|
||||
|
||||
var state = $"requestId: {requestId}, previousRequestId: {previousRequestId}, message: {message}";
|
||||
|
||||
_logger.Log(LogLevel.Critical, default(EventId), state, exception, _func);
|
||||
}
|
||||
|
||||
private string GetOcelotRequestId()
|
||||
@ -81,4 +111,4 @@ namespace Ocelot.Logging
|
||||
return requestId.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@
|
||||
|
||||
private static void ConfigureDiagnosticListener(IApplicationBuilder builder)
|
||||
{
|
||||
var env = builder.ApplicationServices.GetService<IHostingEnvironment>();
|
||||
var env = builder.ApplicationServices.GetService<IWebHostEnvironment>();
|
||||
var listener = builder.ApplicationServices.GetService<OcelotDiagnosticListener>();
|
||||
var diagnosticListener = builder.ApplicationServices.GetService<DiagnosticListener>();
|
||||
diagnosticListener.SubscribeWithAdapter(listener);
|
||||
|
@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||
<NETStandardImplicitPackageVersion>2.0.0</NETStandardImplicitPackageVersion>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||
<Description>Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.</Description>
|
||||
<AssemblyTitle>Ocelot</AssemblyTitle>
|
||||
@ -25,16 +23,20 @@
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.MiddlewareAnalysis" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.2.0">
|
||||
<PackageReference Include="FluentValidation" Version="8.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.MiddlewareAnalysis" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="3.0.0">
|
||||
<NoWarn>NU1701</NoWarn>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user