Skip to content

Commit

Permalink
Integration of feedback by @RaynaldM in the PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclayman committed Aug 5, 2023
1 parent 6af617f commit 4bc297a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public class FileUpstreamHeaderRoutingOptions
{
public FileUpstreamHeaderRoutingOptions()
{
Headers = new();
Headers = new Dictionary<string, IList<string>>();
TriggerOn = string.Empty;
}

public Dictionary<string, List<string>> Headers { get; set; }
public IDictionary<string, IList<string>> Headers { get; set; }

public string TriggerOn { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ocelot/Configuration/UpstreamHeaderRoutingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Ocelot.Configuration
{
public class UpstreamHeaderRoutingOptions
{
public UpstreamHeaderRoutingOptions(Dictionary<string, HashSet<string>> headers, UpstreamHeaderRoutingTriggerMode mode)
public UpstreamHeaderRoutingOptions(IReadOnlyDictionary<string, HashSet<string>> headers, UpstreamHeaderRoutingTriggerMode mode)
{
Headers = new UpstreamRoutingHeaders(headers);
Mode = mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ private static bool AreDuplicateUpstreamRoutingHeaders(FileRoute first, FileRout

foreach (var (key, values) in first.UpstreamHeaderRoutingOptions.Headers)
{
IDictionary<string, List<string>> secondHeaders = second.UpstreamHeaderRoutingOptions.Headers;
if (!secondHeaders.TryGetValue(key, out List<string> secondHeaderValues))
IDictionary<string, IList<string>> secondHeaders = second.UpstreamHeaderRoutingOptions.Headers;
if (!secondHeaders.TryGetValue(key, out IList<string> secondHeaderValues))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ private static bool RouteIsApplicableToThisRequest(Route route, string httpMetho

private static bool RouteHasHttpMethod(Route route, string httpMethod)
{
return route.UpstreamHttpMethod.Select(x => x.Method.ToLower()).Contains(httpMethod.ToLower());
httpMethod = httpMethod.ToLower();
return route.UpstreamHttpMethod.Select(x => x.Method.ToLower()).Contains(httpMethod);
}

private static bool RouteHasRequiredUpstreamHeaders(Route route, IHeaderDictionary requestHeaders)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void GivenTheseFileUpstreamHeaderRoutingOptions()
{
_fileUpstreamHeaderRoutingOptions = new FileUpstreamHeaderRoutingOptions()
{
Headers = new Dictionary<string, List<string>>()
Headers = new Dictionary<string, IList<string>>()
{
{ "Header1", new List<string>() { "Value1", "Value2" }},
{ "Header2", new List<string>() { "Value3" }},
Expand Down

0 comments on commit 4bc297a

Please sign in to comment.