mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 19:08:16 +08:00
Use registered scheme from Eureka (#1087)
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
|
||||
if (instances != null && instances.Any())
|
||||
{
|
||||
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port), "", "", new List<string>())));
|
||||
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), "", "", new List<string>())));
|
||||
}
|
||||
|
||||
return Task.FromResult(services);
|
||||
|
@ -37,7 +37,10 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
|
||||
return;
|
||||
}
|
||||
|
||||
context.DownstreamRequest.Scheme = context.DownstreamReRoute.DownstreamScheme;
|
||||
if (!string.IsNullOrEmpty(context.DownstreamReRoute.DownstreamScheme))
|
||||
{
|
||||
context.DownstreamRequest.Scheme = context.DownstreamReRoute.DownstreamScheme;
|
||||
}
|
||||
|
||||
if (ServiceFabricRequest(context))
|
||||
{
|
||||
|
@ -45,6 +45,11 @@ namespace Ocelot.LoadBalancer.Middleware
|
||||
context.DownstreamRequest.Port = hostAndPort.Data.DownstreamPort;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hostAndPort.Data.Scheme))
|
||||
{
|
||||
context.DownstreamRequest.Scheme = hostAndPort.Data.Scheme;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _next.Invoke(context);
|
||||
|
@ -34,7 +34,7 @@ namespace Ocelot.ServiceDiscovery
|
||||
|
||||
foreach (var downstreamAddress in reRoute.DownstreamAddresses)
|
||||
{
|
||||
var service = new Service(reRoute.ServiceName, new ServiceHostAndPort(downstreamAddress.Host, downstreamAddress.Port), string.Empty, string.Empty, new string[0]);
|
||||
var service = new Service(reRoute.ServiceName, new ServiceHostAndPort(downstreamAddress.Host, downstreamAddress.Port, reRoute.DownstreamScheme), string.Empty, string.Empty, new string[0]);
|
||||
|
||||
services.Add(service);
|
||||
}
|
||||
|
@ -8,8 +8,13 @@
|
||||
DownstreamPort = downstreamPort;
|
||||
}
|
||||
|
||||
public ServiceHostAndPort(string downstreamHost, int downstreamPort, string scheme)
|
||||
: this(downstreamHost, downstreamPort) => Scheme = scheme;
|
||||
|
||||
public string DownstreamHost { get; }
|
||||
|
||||
public int DownstreamPort { get; }
|
||||
public int DownstreamPort { get; }
|
||||
|
||||
public string Scheme { get; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user