mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
This commit is contained in:
parent
e636cefdb1
commit
fffc4c8d3c
@ -49,7 +49,8 @@ namespace Ocelot.DownstreamRouteFinder.Finder
|
|||||||
|
|
||||||
private bool RouteIsApplicableToThisRequest(ReRoute reRoute, string httpMethod, string upstreamHost)
|
private bool RouteIsApplicableToThisRequest(ReRoute reRoute, string httpMethod, string upstreamHost)
|
||||||
{
|
{
|
||||||
return reRoute.UpstreamHttpMethod.Count == 0 || reRoute.UpstreamHttpMethod.Select(x => x.Method.ToLower()).Contains(httpMethod.ToLower()) && !(!string.IsNullOrEmpty(reRoute.UpstreamHost) && reRoute.UpstreamHost != upstreamHost);
|
return (reRoute.UpstreamHttpMethod.Count == 0 || reRoute.UpstreamHttpMethod.Select(x => x.Method.ToLower()).Contains(httpMethod.ToLower())) &&
|
||||||
|
(string.IsNullOrEmpty(reRoute.UpstreamHost) || reRoute.UpstreamHost == upstreamHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DownstreamRoute GetPlaceholderNamesAndValues(string path, ReRoute reRoute)
|
private DownstreamRoute GetPlaceholderNamesAndValues(string path, ReRoute reRoute)
|
||||||
|
@ -583,6 +583,19 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
|
|||||||
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
||||||
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("someUpstreamPath", 1))
|
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("someUpstreamPath", 1))
|
||||||
.WithUpstreamHost("MATCH")
|
.WithUpstreamHost("MATCH")
|
||||||
|
.Build(),
|
||||||
|
new ReRouteBuilder()
|
||||||
|
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
|
||||||
|
.WithDownstreamPathTemplate("someDownstreamPath")
|
||||||
|
.WithUpstreamPathTemplate("someUpstreamPath")
|
||||||
|
.WithUpstreamHttpMethod(new List<string> { }) // empty list of methods
|
||||||
|
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("someUpstreamPath", 1))
|
||||||
|
.WithUpstreamHost("MATCH")
|
||||||
|
.Build())
|
||||||
|
.WithUpstreamPathTemplate("someUpstreamPath")
|
||||||
|
.WithUpstreamHttpMethod(new List<string> { }) // empty list of methods
|
||||||
|
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("someUpstreamPath", 1))
|
||||||
|
.WithUpstreamHost("MATCH")
|
||||||
.Build()
|
.Build()
|
||||||
}, string.Empty, serviceProviderConfig
|
}, string.Empty, serviceProviderConfig
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user