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 Mar 26, 2022
1 parent 36ad6e1 commit b9ff360
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 @@ -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;
}
}
}

0 comments on commit b9ff360

Please sign in to comment.