mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-28 15:12:51 +08:00

* cache key now can generate from query string for request with Get Methods and request content for requests with post methods * MD5Helper Added. OutputCacheMiddleware now can generate cache key using method, url and content * ConsulFileConfigurationPollerOption created. consul poller option bug fixed * ConsulFileConfigurationPollerOptionTest created
30 lines
1.3 KiB
C#
30 lines
1.3 KiB
C#
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<ServiceDiscoveryFinderDelegate>(ConsulProviderFactory.Get);
|
|
builder.Services.AddSingleton<IConsulClientFactory, ConsulClientFactory>();
|
|
builder.Services.RemoveAll(typeof(IFileConfigurationPollerOptions));
|
|
builder.Services.AddSingleton<IFileConfigurationPollerOptions, ConsulFileConfigurationPollerOption>();
|
|
return builder;
|
|
}
|
|
|
|
public static IOcelotBuilder AddConfigStoredInConsul(this IOcelotBuilder builder)
|
|
{
|
|
builder.Services.AddSingleton<OcelotMiddlewareConfigurationDelegate>(ConsulMiddlewareConfigurationProvider.Get);
|
|
builder.Services.AddHostedService<FileConfigurationPoller>();
|
|
builder.Services.AddSingleton<IFileConfigurationRepository, ConsulFileConfigurationRepository>();
|
|
return builder;
|
|
}
|
|
}
|
|
}
|