mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-18 23:28:14 +08:00
#559 +semver: breaking always use environment when working out AddOcelot on builder
This commit is contained in:
@ -107,7 +107,7 @@ Instead of adding the configuration directly e.g. AddJsonFile("ocelot.json") you
|
||||
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", true, true)
|
||||
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
|
||||
.AddOcelot()
|
||||
.AddOcelot(hostingContext.HostingEnvironment)
|
||||
.AddEnvironmentVariables();
|
||||
})
|
||||
|
||||
@ -117,6 +117,22 @@ The way Ocelot merges the files is basically load them, loop over them, add any
|
||||
|
||||
At the moment there is no validation at this stage it only happens when Ocelot validates the final merged configuration. This is something to be aware of when you are investigating problems. I would advise always checking what is in ocelot.json if you have any problems.
|
||||
|
||||
You can also give Ocelot a specific path to look in for the configuration files like below.
|
||||
|
||||
.. code-block:: csharp
|
||||
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
config
|
||||
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", true, true)
|
||||
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
|
||||
.AddOcelot("/foo/bar", hostingContext.HostingEnvironment)
|
||||
.AddEnvironmentVariables();
|
||||
})
|
||||
|
||||
Ocelot needs the HostingEnvironment so it know's to exclude anything environment specific from the algorithm.
|
||||
|
||||
Store configuration in consul
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
Reference in New Issue
Block a user