Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加一个扩展选项 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

增加一个扩展选项 #19

wants to merge 1 commit into from

Conversation

DwGoing
Copy link

@DwGoing DwGoing commented Feb 14, 2023

· 原扩展因为无法提供自定义的configuration参数,导致如果提供了自定义的Ocelot配置,Nacos的配置项必须在Ocelot的配置节点同级目录下,如:

{
    "Gateways": {
        "GlobalConfiguration": {
            ...
        },
        "Routes": [
            ...
        ],
        "Nacos": {
            ...
        }
    }
}
services.AddOcelot(gatewaysConfiguration).AddNacosDiscovery("Nacos");

· 新的扩展方法可以分离两个配置,并且更方便Ocelot的配置动态从Nacos获取,如:

{
    "Nacos": {
        ...
    },
    // 以下配置在Nacos中配置
    "Gateways": {
        "GlobalConfiguration": {
            ...
        },
        "Routes": [
            ...
        ]
    }
}
var rootConfiguration;
var nacosConfiguration; // 从Nacos获取
services.AddOcelot(nacosConfiguration.GetConfiguration("Gateways")).AddNacosDiscovery(rootConfiguration, "Nacos");

· 原扩展因为无法提供自定义的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");
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant