Skip to content

New Feature - Merge configuration files #296

@AaronFixer

Description

@AaronFixer

Expected Behavior / New Feature

This may already be a feature but I see no mention of it in the documentation and it isn't working in my project.

It would be good to support multiple .json files, potentially with better naming conventions. I have an app with a number of services and routes, and it would be nice to separate them out into dedicated files rather then have one huge configuration.json.

For example:

  • AccountRoutes.json <- Would have all routes for the account controller/service
  • ComponentActions.json <- Would have all the routes for component actions controller/service

etc. etc.

Is this already possible? It seems that when I define multiple .AddJsonFile() it only picks up the routes in the last file it pinks up with the ReRoutes field.

Activity

changed the title [-]Supporting multiple *.json files?[/-] [+]Supporting multiple json route files?[/+] on Mar 29, 2018
changed the title [-]Supporting multiple json route files?[/-] [+]New Feature - Merge configuration files[/+] on Mar 29, 2018
added
medium effortLikely a few days of development effort
help wantedNot actively being worked on. If you plan to contribute, please drop a note.
on Mar 29, 2018
TomPallister

TomPallister commented on Mar 29, 2018

@TomPallister
Member

@AaronFixer thanks for your interest in the project!

This feature isn't supported yet I will but it on the backlog but if you would like to have a go yourself please feel free to submit a PR.

There are a couple of considerations here.

  1. Ocelot uses configuration.json as a database so a solution would need to take multiple files and merge them into configuration.json or have a second file that ocelot uses as a database (not sure I like this).

  2. Been thinking about this for a while completely change how configuration works. I was thinking of making it more like identity server where it is provided statically in c# / database.

  3. You could just do this yourself in ConfigureAppConfiguration with something like below and it would not need to be part of Ocelot.

.ConfigureAppConfiguration((hostingContext, config) =>
                {
                    merger.Merge();
      
                    config
                        .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
                        .AddJsonFile("configuration.json");
                })

I think 1 and 3 are better options at the moment for me but that could change!

Anyway let me know if you want to give this a try and I will be of as much assistance as I can...otherwise I'm afraid you will have to wait a bit for the feature :(

AaronFixer

AaronFixer commented on Mar 29, 2018

@AaronFixer
Author

For me this is definitely something I think I (and many others) could potentially benefit from with large projects wanting to use a Gateway!

I'll have to do this in my spare time, although I don't imagine it should take too long.

1 and 3 both work. 3 is something I could just use for the time being as a workaround. I'll see if I get a chance to work on a PR for 1. in the meantime.

Thanks for getting back to me!

TomPallister

TomPallister commented on Mar 29, 2018

@TomPallister
Member

Yep I agree this would be a useful feature! If you don't get round to it its on my list and I expect to do it in the next months or so.

added 5 commits that reference this issue on Apr 14, 2018

#296 renamed configuration.json to ocelot.json in preparation

#296 started writing merge code

#296 coming up with ideas for this config merging

#296 still hacking this idea around

#296 will now do a crappy merge on the configuration

added a commit that references this issue on Apr 17, 2018

#296 merged develop into this branch

30 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConfigurationOcelot feature: ConfigurationfeatureA new feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @NicoJuicy@CesarD@TomPallister@raman-m@zhutoutou

      Issue actions

        New Feature - Merge configuration files · Issue #296 · ThreeMammals/Ocelot