From 1671fadea3846cbb0ca7cb90619e97c3d556155a Mon Sep 17 00:00:00 2001 From: Tom Gardham-Pallister Date: Tue, 7 Feb 2017 07:53:41 +0000 Subject: [PATCH] made upstream template use template path object --- src/Ocelot/Configuration/Builder/ReRouteBuilder.cs | 2 +- .../Creator/FileOcelotConfigurationCreator.cs | 8 ++++---- src/Ocelot/Configuration/ReRoute.cs | 8 ++++---- .../DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs | 2 +- src/Ocelot/Values/DownstreamPathTemplate.cs | 4 ++-- .../DownstreamRouteFinder/DownstreamRouteFinderTests.cs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs b/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs index c8bde074..78c96fb5 100644 --- a/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs +++ b/src/Ocelot/Configuration/Builder/ReRouteBuilder.cs @@ -194,7 +194,7 @@ namespace Ocelot.Configuration.Builder public ReRoute Build() { - return new ReRoute(new DownstreamPathTemplate(_downstreamPathTemplate), _upstreamTemplate, _upstreamHttpMethod, _upstreamTemplatePattern, + return new ReRoute(new PathTemplate(_downstreamPathTemplate), new PathTemplate(_upstreamTemplate), _upstreamHttpMethod, _upstreamTemplatePattern, _isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName, _requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement, _isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer, diff --git a/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs index 5a265569..e02fccd5 100644 --- a/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs +++ b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs @@ -131,8 +131,8 @@ namespace Ocelot.Configuration.Creator var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest); var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest); - reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate), - fileReRoute.UpstreamTemplate, + reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate), + new PathTemplate(fileReRoute.UpstreamTemplate), fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated, authOptionsForRoute, claimsToHeaders, claimsToClaims, fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries, @@ -143,8 +143,8 @@ namespace Ocelot.Configuration.Creator } else { - reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate), - fileReRoute.UpstreamTemplate, + reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate), + new PathTemplate(fileReRoute.UpstreamTemplate), fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated, null, new List(), new List(), fileReRoute.RouteClaimsRequirement, isAuthorised, new List(), diff --git a/src/Ocelot/Configuration/ReRoute.cs b/src/Ocelot/Configuration/ReRoute.cs index 278d0746..dbc0d05e 100644 --- a/src/Ocelot/Configuration/ReRoute.cs +++ b/src/Ocelot/Configuration/ReRoute.cs @@ -6,8 +6,8 @@ namespace Ocelot.Configuration { public class ReRoute { - public ReRoute(DownstreamPathTemplate downstreamPathTemplate, - string upstreamTemplate, string upstreamHttpMethod, + public ReRoute(PathTemplate downstreamPathTemplate, + PathTemplate upstreamTemplate, string upstreamHttpMethod, string upstreamTemplatePattern, bool isAuthenticated, AuthenticationOptions authenticationOptions, List configurationHeaderExtractorProperties, @@ -44,8 +44,8 @@ namespace Ocelot.Configuration } public string LoadBalancerKey {get;private set;} - public DownstreamPathTemplate DownstreamPathTemplate { get; private set; } - public string UpstreamTemplate { get; private set; } + public PathTemplate DownstreamPathTemplate { get; private set; } + public PathTemplate UpstreamTemplate { get; private set; } public string UpstreamTemplatePattern { get; private set; } public string UpstreamHttpMethod { get; private set; } public bool IsAuthenticated { get; private set; } diff --git a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs index eacd6912..910f2bb2 100644 --- a/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs +++ b/src/Ocelot/DownstreamRouteFinder/Finder/DownstreamRouteFinder.cs @@ -34,7 +34,7 @@ namespace Ocelot.DownstreamRouteFinder.Finder if (urlMatch.Data.Match) { - var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamTemplate); + var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamTemplate.Value); return new OkResponse(new DownstreamRoute(templateVariableNameAndValues.Data, reRoute)); } diff --git a/src/Ocelot/Values/DownstreamPathTemplate.cs b/src/Ocelot/Values/DownstreamPathTemplate.cs index a4c720eb..b0b53418 100644 --- a/src/Ocelot/Values/DownstreamPathTemplate.cs +++ b/src/Ocelot/Values/DownstreamPathTemplate.cs @@ -1,8 +1,8 @@ namespace Ocelot.Values { - public class DownstreamPathTemplate + public class PathTemplate { - public DownstreamPathTemplate(string value) + public PathTemplate(string value) { Value = value; } diff --git a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs index dc9978b3..8abb9a61 100644 --- a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs +++ b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs @@ -143,7 +143,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder private void ThenTheUrlMatcherIsCalledCorrectly() { _mockMatcher - .Verify(x => x.Match(_upstreamUrlPath, _reRoutesConfig[0].UpstreamTemplate), Times.Once); + .Verify(x => x.Match(_upstreamUrlPath, _reRoutesConfig[0].UpstreamTemplate.Value), Times.Once); } private void GivenTheUrlMatcherReturns(Response match)