Ocelot: Specify specific folder for config.AddOcelot()

Created on 18 Jul 2018  路  6Comments  路  Source: ThreeMammals/Ocelot

New Feature

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.

Motivation for New Feature

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:

  • OcelotConfig

    • Development

    • ocelot.global.json

    • ocelot.FirstAPI.json

    • ocelot.SecondAPI.json

    • ocelot.ThirdAPI.json

    • Production

    • ocelot.global.json

    • ocelot.FirstAPI.json

    • ocelot.SecondAPI.json

    • ocelot.ThirdAPI.json

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}");

Specifications

  • Version: 8.0.0

Notes

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.

enhancement good first issue help wanted medium effort merged

All 6 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

secret-agent-B picture secret-agent-B  路  4Comments

Marusyk picture Marusyk  路  3Comments

mogliang picture mogliang  路  3Comments

lucianoscastro picture lucianoscastro  路  3Comments

jefferson picture jefferson  路  3Comments