Skip to content

Commit

Permalink
Reimplementation of changes for PR 964 (GH ticket ThreeMammals#360) f…
Browse files Browse the repository at this point in the history
…or the current code base.
  • Loading branch information
mrclayman authored and raman-m committed Jul 27, 2023
1 parent 433dfca commit 023118c
Show file tree
Hide file tree
Showing 21 changed files with 2,416 additions and 1,827 deletions.
153 changes: 80 additions & 73 deletions src/Ocelot/Configuration/Builder/RouteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,83 @@
using Ocelot.Configuration.File;

using Ocelot.Values;

namespace Ocelot.Configuration.Builder
{
public class RouteBuilder
{
private UpstreamPathTemplate _upstreamTemplatePattern;
private List<HttpMethod> _upstreamHttpMethod;
private string _upstreamHost;
private List<DownstreamRoute> _downstreamRoutes;
private List<AggregateRouteConfig> _downstreamRoutesConfig;
private string _aggregator;

public RouteBuilder()
{
_downstreamRoutes = new List<DownstreamRoute>();
_downstreamRoutesConfig = new List<AggregateRouteConfig>();
}

public RouteBuilder WithDownstreamRoute(DownstreamRoute value)
{
_downstreamRoutes.Add(value);
return this;
}

public RouteBuilder WithDownstreamRoutes(List<DownstreamRoute> value)
{
_downstreamRoutes = value;
return this;
}

public RouteBuilder WithUpstreamHost(string upstreamAddresses)
{
_upstreamHost = upstreamAddresses;
return this;
}

public RouteBuilder WithUpstreamPathTemplate(UpstreamPathTemplate input)
{
_upstreamTemplatePattern = input;
return this;
}

public RouteBuilder WithUpstreamHttpMethod(List<string> input)
{
_upstreamHttpMethod = (input.Count == 0) ? new List<HttpMethod>() : input.Select(x => new HttpMethod(x.Trim())).ToList();
return this;
}

public RouteBuilder WithAggregateRouteConfig(List<AggregateRouteConfig> aggregateRouteConfigs)
{
_downstreamRoutesConfig = aggregateRouteConfigs;
return this;
}

public RouteBuilder WithAggregator(string aggregator)
{
_aggregator = aggregator;
return this;
}

public Route Build()
{
return new Route(
_downstreamRoutes,
_downstreamRoutesConfig,
_upstreamHttpMethod,
_upstreamTemplatePattern,
_upstreamHost,
_aggregator
);
}
}
}

namespace Ocelot.Configuration.Builder
{
public class RouteBuilder
{
private UpstreamPathTemplate _upstreamTemplatePattern;
private List<HttpMethod> _upstreamHttpMethod;
private string _upstreamHost;
private List<DownstreamRoute> _downstreamRoutes;
private List<AggregateRouteConfig> _downstreamRoutesConfig;
private string _aggregator;
private UpstreamHeaderRoutingOptions _upstreamHeaderRoutingOptions;

public RouteBuilder()
{
_downstreamRoutes = new List<DownstreamRoute>();
_downstreamRoutesConfig = new List<AggregateRouteConfig>();
}

public RouteBuilder WithDownstreamRoute(DownstreamRoute value)
{
_downstreamRoutes.Add(value);
return this;
}

public RouteBuilder WithDownstreamRoutes(List<DownstreamRoute> value)
{
_downstreamRoutes = value;
return this;
}

public RouteBuilder WithUpstreamHost(string upstreamAddresses)
{
_upstreamHost = upstreamAddresses;
return this;
}

public RouteBuilder WithUpstreamPathTemplate(UpstreamPathTemplate input)
{
_upstreamTemplatePattern = input;
return this;
}

public RouteBuilder WithUpstreamHttpMethod(List<string> input)
{
_upstreamHttpMethod = (input.Count == 0) ? new List<HttpMethod>() : input.Select(x => new HttpMethod(x.Trim())).ToList();
return this;
}

public RouteBuilder WithAggregateRouteConfig(List<AggregateRouteConfig> aggregateRouteConfigs)
{
_downstreamRoutesConfig = aggregateRouteConfigs;
return this;
}

public RouteBuilder WithAggregator(string aggregator)
{
_aggregator = aggregator;
return this;
}

public RouteBuilder WithUpstreamHeaderRoutingOptions(UpstreamHeaderRoutingOptions routingOptions)
{
_upstreamHeaderRoutingOptions = routingOptions;
return this;
}

public Route Build()
{
return new Route(
_downstreamRoutes,
_downstreamRoutesConfig,
_upstreamHttpMethod,
_upstreamTemplatePattern,
_upstreamHost,
_aggregator,
_upstreamHeaderRoutingOptions);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Ocelot.Configuration.File;

namespace Ocelot.Configuration.Creator;

public interface IUpstreamHeaderRoutingOptionsCreator
{
UpstreamHeaderRoutingOptions Create(FileUpstreamHeaderRoutingOptions options);
}
Loading

0 comments on commit 023118c

Please sign in to comment.