Open
Conversation
· 原扩展因为无法提供自定义的configuration参数,导致如果提供了自定义的Ocelot配置,Nacos的配置项必须在Ocelot的配置节点同级目录下,如:
``` json
{
"Gateways": {
"GlobalConfiguration": {
...
},
"Routes": [
...
],
"Nacos": {
...
}
}
}
```
``` csharp
services.AddOcelot(gatewaysConfiguration).AddNacosDiscovery("Nacos");
```
· 新的扩展方法可以分离两个配置,并且更方便Ocelot的配置动态从Nacos获取,如:
``` json
{
"Nacos": {
...
},
// 以下配置在Nacos中配置
"Gateways": {
"GlobalConfiguration": {
...
},
"Routes": [
...
]
}
}
```
``` csharp
var rootConfiguration;
var nacosConfiguration; // 从Nacos获取
services.AddOcelot(nacosConfiguration.GetConfiguration("Gateways")).AddNacosDiscovery(rootConfiguration, "Nacos");
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
· 原扩展因为无法提供自定义的configuration参数,导致如果提供了自定义的Ocelot配置,Nacos的配置项必须在Ocelot的配置节点同级目录下,如:
{ "Gateways": { "GlobalConfiguration": { ... }, "Routes": [ ... ], "Nacos": { ... } } }· 新的扩展方法可以分离两个配置,并且更方便Ocelot的配置动态从Nacos获取,如:
{ "Nacos": { ... }, // 以下配置在Nacos中配置 "Gateways": { "GlobalConfiguration": { ... }, "Routes": [ ... ] } }