You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Tiobon.Web.Core/Ocelot.Provider.Nacos/NacosProviderFactory.cs

21 lines
669 B

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Nacos.V2;
using Ocelot.Provider.Nacos.NacosClient.V2;
using Ocelot.ServiceDiscovery;
namespace Ocelot.Provider.Nacos;
public static class NacosProviderFactory
{
public static ServiceDiscoveryFinderDelegate Get = (provider, config, route) =>
{
var client = provider.GetService<INacosNamingService>();
if (config.Type?.ToLower() == "nacos" && client != null)
{
var option = provider.GetService<IOptions<NacosAspNetOptions>>();
return new Nacos(route.ServiceName, client, option);
}
return null;
};
}