public static IOcelotBuilder WithReplaceHandler(this IOcelotBuilder builder) { if (!_withReplaceHandler) { builder .WithRouteExtensions(); builder.AddDelegatingHandler <ReplaceHandler>(); _withReplaceHandler = true; } return(builder); }
public static IOcelotBuilder WithConfigurationRepository(this IOcelotBuilder builder, string configKey = "Ocelot.Extensions:Configuration") { if (!_withConfigurationRepository) { builder.Services.AddHttpClient(); builder.WithRouteExtensions(); var config = new OcelotConfiguration(); builder.Configuration.Bind(configKey, config); builder.Services.AddSingleton(config); builder.Services.AddSingleton <IFileConfigurationRepositoryExtended>( sp => new SnapshotConfigurationRepositoryExtended( new DiskFileConfigurationRepositoryExtended(sp.GetRequiredService <IHostingEnvironment>()))); builder.Services.AddHostedService <OcelotConfigurationSyncAgent>(); _withConfigurationRepository = true; } return(builder); }