Skip to content

Commit

Permalink
Added AddOcelot Configbuilder Overload
Browse files Browse the repository at this point in the history
Added an AddOcelot overload to load FileConfiguration directly from the application, so that all the routes could be made configurable and could be load from anywhere.
  • Loading branch information
vijay-karavadra authored and raman-m committed May 13, 2023
1 parent bc25f4e commit 563aa04
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Ocelot/DependencyInjection/ConfigurationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,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;
}
}
}

0 comments on commit 563aa04

Please sign in to comment.