mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
made upstream template use template path object
This commit is contained in:
parent
b4ef277c3e
commit
1671fadea3
@ -194,7 +194,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
|
|
||||||
public ReRoute Build()
|
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,
|
_isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName,
|
||||||
_requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement,
|
_requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement,
|
||||||
_isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer,
|
_isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer,
|
||||||
|
@ -131,8 +131,8 @@ namespace Ocelot.Configuration.Creator
|
|||||||
var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
|
var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
|
||||||
var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
|
var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
|
||||||
|
|
||||||
reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
|
reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate),
|
||||||
fileReRoute.UpstreamTemplate,
|
new PathTemplate(fileReRoute.UpstreamTemplate),
|
||||||
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
||||||
authOptionsForRoute, claimsToHeaders, claimsToClaims,
|
authOptionsForRoute, claimsToHeaders, claimsToClaims,
|
||||||
fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
|
fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
|
||||||
@ -143,8 +143,8 @@ namespace Ocelot.Configuration.Creator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
|
reRoute = new ReRoute(new PathTemplate(fileReRoute.DownstreamPathTemplate),
|
||||||
fileReRoute.UpstreamTemplate,
|
new PathTemplate(fileReRoute.UpstreamTemplate),
|
||||||
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
|
||||||
null, new List<ClaimToThing>(), new List<ClaimToThing>(),
|
null, new List<ClaimToThing>(), new List<ClaimToThing>(),
|
||||||
fileReRoute.RouteClaimsRequirement, isAuthorised, new List<ClaimToThing>(),
|
fileReRoute.RouteClaimsRequirement, isAuthorised, new List<ClaimToThing>(),
|
||||||
|
@ -6,8 +6,8 @@ namespace Ocelot.Configuration
|
|||||||
{
|
{
|
||||||
public class ReRoute
|
public class ReRoute
|
||||||
{
|
{
|
||||||
public ReRoute(DownstreamPathTemplate downstreamPathTemplate,
|
public ReRoute(PathTemplate downstreamPathTemplate,
|
||||||
string upstreamTemplate, string upstreamHttpMethod,
|
PathTemplate upstreamTemplate, string upstreamHttpMethod,
|
||||||
string upstreamTemplatePattern,
|
string upstreamTemplatePattern,
|
||||||
bool isAuthenticated, AuthenticationOptions authenticationOptions,
|
bool isAuthenticated, AuthenticationOptions authenticationOptions,
|
||||||
List<ClaimToThing> configurationHeaderExtractorProperties,
|
List<ClaimToThing> configurationHeaderExtractorProperties,
|
||||||
@ -44,8 +44,8 @@ namespace Ocelot.Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string LoadBalancerKey {get;private set;}
|
public string LoadBalancerKey {get;private set;}
|
||||||
public DownstreamPathTemplate DownstreamPathTemplate { get; private set; }
|
public PathTemplate DownstreamPathTemplate { get; private set; }
|
||||||
public string UpstreamTemplate { get; private set; }
|
public PathTemplate UpstreamTemplate { get; private set; }
|
||||||
public string UpstreamTemplatePattern { get; private set; }
|
public string UpstreamTemplatePattern { get; private set; }
|
||||||
public string UpstreamHttpMethod { get; private set; }
|
public string UpstreamHttpMethod { get; private set; }
|
||||||
public bool IsAuthenticated { get; private set; }
|
public bool IsAuthenticated { get; private set; }
|
||||||
|
@ -34,7 +34,7 @@ namespace Ocelot.DownstreamRouteFinder.Finder
|
|||||||
|
|
||||||
if (urlMatch.Data.Match)
|
if (urlMatch.Data.Match)
|
||||||
{
|
{
|
||||||
var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamTemplate);
|
var templateVariableNameAndValues = _urlPathPlaceholderNameAndValueFinder.Find(upstreamUrlPath, reRoute.UpstreamTemplate.Value);
|
||||||
|
|
||||||
return new OkResponse<DownstreamRoute>(new DownstreamRoute(templateVariableNameAndValues.Data, reRoute));
|
return new OkResponse<DownstreamRoute>(new DownstreamRoute(templateVariableNameAndValues.Data, reRoute));
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace Ocelot.Values
|
namespace Ocelot.Values
|
||||||
{
|
{
|
||||||
public class DownstreamPathTemplate
|
public class PathTemplate
|
||||||
{
|
{
|
||||||
public DownstreamPathTemplate(string value)
|
public PathTemplate(string value)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
|
|||||||
private void ThenTheUrlMatcherIsCalledCorrectly()
|
private void ThenTheUrlMatcherIsCalledCorrectly()
|
||||||
{
|
{
|
||||||
_mockMatcher
|
_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<UrlMatch> match)
|
private void GivenTheUrlMatcherReturns(Response<UrlMatch> match)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user