mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-12-26 04:05:48 +08:00
22 lines
532 B
C#
22 lines
532 B
C#
namespace Ocelot.Provider.Consul
|
|
{
|
|
using global::Consul;
|
|
using System;
|
|
|
|
public class ConsulClientFactory : IConsulClientFactory
|
|
{
|
|
public IConsulClient Get(ConsulRegistryConfiguration config)
|
|
{
|
|
return new ConsulClient(c =>
|
|
{
|
|
c.Address = new Uri($"http://{config.Host}:{config.Port}");
|
|
|
|
if (!string.IsNullOrEmpty(config?.Token))
|
|
{
|
|
c.Token = config.Token;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|