I use the AddOcelot extension-method on IConfigurationBuilder to configure Ocelot in a project I'm working on. The default implementation looks in the current folder for config files and combines these into an ocelot.json file.
I would like to have the ability to specify a specific folder when using config.AddOcelot.
I like to define the reroutes for every API I want to publish using Ocelot in a separate config file. The new feature would enable me to have a separate folder per environment in which I can place these config files. Consider the next folder structure:
Now I can combine all the ReRoutes specified in the separate config files for a speific environment by calling:
config.AddOcelot($"OcelotConfig\\{hostingContext.HostingEnvironment.EnvironmentName}");
In a project that I'm working on I've already added an overload of the AddOcelot extension-method on IConfigurationBuilder that accepts a folder. This works like a charm. So if this is considered a valuable addition, I can make a PR.
Another approach would be to take the Environment into consideration when traversing the config files. But this would be my second choice.
@EdwinVW thanks for your interest in Ocelot. Yes I would love a PR for this! Sounds useful.
Will do. Code is complete and unit-tests are green. Will create PR shortly.
Can you assign me to the issue?
@EdwinVW awesome thanks! I will review ASAP.
@EdwinVW good PR thank you very much. I will release this with next version of Ocelot.
Great, thanks for the fast review and merge!
Released in version 8.0.1