diff --git a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs index 107da2c2b9..df72c1f8ea 100644 --- a/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs +++ b/src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs @@ -81,5 +81,20 @@ public static IConfigurationBuilder AddOcelot(this IConfigurationBuilder builder return builder; } + + + public static IConfigurationBuilder AddOcelot( + this IConfigurationBuilder builder, FileConfiguration fileConfiguration, IWebHostEnvironment env) + { + const string primaryConfigFile = "ocelot.json"; + + var json = JsonConvert.SerializeObject(fileConfiguration); + + File.WriteAllText(primaryConfigFile, json); + + builder.AddJsonFile(primaryConfigFile, false, false); + + return builder; + } } }