Now supports the same upstream url by difrenciating by http method. Also broke up the proxy middleware into three seperate pieces that do their thing and stick something into the OWIN context

This commit is contained in:
TomPallister
2016-10-04 21:30:16 +01:00
parent da1957311b
commit ab8407e7dc
17 changed files with 227 additions and 82 deletions

View File

@ -4,5 +4,6 @@
{
public string DownstreamTemplate { get; set; }
public string UpstreamTemplate { get; set; }
public string UpstreamHttpMethod { get; set; }
}
}

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Options;
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.UrlMatcher;
@ -16,9 +18,9 @@ namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
_urlMatcher = urlMatcher;
}
public Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath)
public Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath, string upstreamHttpMethod)
{
foreach (var template in _configuration.Value.ReRoutes)
foreach (var template in _configuration.Value.ReRoutes.Where(r => string.Equals(r.UpstreamHttpMethod, upstreamHttpMethod, StringComparison.CurrentCultureIgnoreCase)))
{
var urlMatch = _urlMatcher.Match(upstreamUrlPath, template.UpstreamTemplate);

View File

@ -4,6 +4,6 @@ namespace Ocelot.Library.Infrastructure.DownstreamRouteFinder
{
public interface IDownstreamRouteFinder
{
Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath);
Response<DownstreamRoute> FindDownstreamRoute(string upstreamUrlPath, string upstreamHttpMethod);
}
}