|
14 | 14 | public class DownstreamRouteCreator : IDownstreamRouteProvider |
15 | 15 | { |
16 | 16 | private readonly IQoSOptionsCreator _qoSOptionsCreator; |
| 17 | + private readonly IDownstreamServiceFinder _serviceFinder; |
17 | 18 | private readonly ConcurrentDictionary<string, OkResponse<DownstreamRoute>> _cache; |
18 | 19 |
|
19 | | - public DownstreamRouteCreator(IQoSOptionsCreator qoSOptionsCreator) |
| 20 | + public DownstreamRouteCreator(IQoSOptionsCreator qoSOptionsCreator, IDownstreamServiceFinder serviceFinder) |
20 | 21 | { |
21 | 22 | _qoSOptionsCreator = qoSOptionsCreator; |
| 23 | + _serviceFinder = serviceFinder; |
22 | 24 | _cache = new ConcurrentDictionary<string, OkResponse<DownstreamRoute>>(); |
23 | 25 | } |
24 | 26 |
|
25 | 27 | public Response<DownstreamRoute> Get(string upstreamUrlPath, string upstreamQueryString, string upstreamHttpMethod, IInternalConfiguration configuration, string upstreamHost) |
26 | 28 | { |
27 | | - var serviceName = GetServiceName(upstreamUrlPath); |
| 29 | + var serviceName = _serviceFinder.GetServiceName(upstreamUrlPath, upstreamQueryString, upstreamHttpMethod, upstreamHost, configuration); |
28 | 30 |
|
29 | 31 | var downstreamPath = GetDownstreamPath(upstreamUrlPath); |
30 | 32 |
|
@@ -108,19 +110,6 @@ private static string GetDownstreamPath(string upstreamUrlPath) |
108 | 110 | .Substring(upstreamUrlPath.IndexOf('/', 1)); |
109 | 111 | } |
110 | 112 |
|
111 | | - private static string GetServiceName(string upstreamUrlPath) |
112 | | - { |
113 | | - if (upstreamUrlPath.IndexOf('/', 1) == -1) |
114 | | - { |
115 | | - return upstreamUrlPath |
116 | | - .Substring(1); |
117 | | - } |
118 | | - |
119 | | - return upstreamUrlPath |
120 | | - .Substring(1, upstreamUrlPath.IndexOf('/', 1)) |
121 | | - .TrimEnd('/'); |
122 | | - } |
123 | | - |
124 | 113 | private string CreateLoadBalancerKey(string downstreamTemplatePath, string httpMethod, LoadBalancerOptions loadBalancerOptions) |
125 | 114 | { |
126 | 115 | if (!string.IsNullOrEmpty(loadBalancerOptions.Type) && !string.IsNullOrEmpty(loadBalancerOptions.Key) && loadBalancerOptions.Type == nameof(CookieStickySessions)) |
|
0 commit comments