-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
ConfigurationOcelot feature: ConfigurationOcelot feature: ConfigurationfeatureA new featureA new feature
Description
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.
Metadata
Metadata
Assignees
Labels
ConfigurationOcelot feature: ConfigurationOcelot feature: ConfigurationfeatureA new featureA new feature
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Supporting multiple *.json files?[/-][+]Supporting multiple json route files?[/+][-]Supporting multiple json route files?[/-][+]New Feature - Merge configuration files[/+]TomPallister commentedon Mar 29, 2018
@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.
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).
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.
You could just do this yourself in ConfigureAppConfiguration with something like below and it would not need to be part of Ocelot.
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 commentedon Mar 29, 2018
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 commentedon Mar 29, 2018
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.
#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
#296 merged develop into this branch
15 remaining items
Faisal-developer commentedon Apr 29, 2020
@zhutoutou use this
NicoJuicy commentedon Jan 28, 2021
A bit better formatting, it wasn't clear what changed to me ( fyi it's the part with wrapping
ConfigureAppConfiguration
withConfigureWebHostDefaults
:raman-m commentedon Nov 11, 2023
Hi César!
Are you still with Ocelot?
FYI #1183
CesarD commentedon Nov 11, 2023
No, sorry, I moved onto
bla-bla
since quite a while ago.raman-m commentedon Nov 11, 2023
@CesarD LoL It is OK that you've moved to another gateway.
I found your past comments really valuable, and we can include these requirements as extra ones to #651 and #1183
CesarD commentedon Nov 11, 2023
Yeah, sorry, is just that for a couple years there was no movement and it was difficult to justify implementing Ocelot while there was another MS-backed project doing similar stuff and being actively developed... 😅
raman-m commentedon Nov 11, 2023
@CesarD Hmm... Bla-bla gateway can merge configuration files, right? If Yes, could you share links to me plz?
This article? Multiple Configuration Sources
Don't you mind if I invite you to review the code and features of PR #1183 in a week?
CesarD commentedon Nov 11, 2023
Well, bla-bla gateway doesn't require to load the configuration from a specific file or type of files, you can very well have its config in the appsettings.json directly and you just need to specifiy the section where you want to pull the config from... If you want to load extra files into the configuration it's up to you, as long as the files don't overlap same configurations between each other, so it provides another kind of flexibility that I got used to.
Perhaps you can adapt Ocelot likewise...
BTW, I don't mind being invited for review 😉
raman-m commentedon Nov 18, 2023
Aha! Especially when you have a team of 3+ full time senior developers on-site at Microsoft with bla-bla salaries. 😛
Yeap! Ocelot has strange design of configuration feature based on ocelot.json file. We will discuss and plan to migrate to appsettings.json with significant refactoring of Configuration feature. Current design is ugly, and developers are confused that they must write special files to configure app instead of well-known ASP.NET approach to use appsettings.json.