|
5 | 5 | using Ocelot.Configuration.File;
|
6 | 6 |
|
7 | 7 | using Ocelot.Values;
|
8 |
| - |
9 |
| -namespace Ocelot.Configuration.Builder |
10 |
| -{ |
11 |
| - public class RouteBuilder |
12 |
| - { |
13 |
| - private UpstreamPathTemplate _upstreamTemplatePattern; |
14 |
| - private List<HttpMethod> _upstreamHttpMethod; |
15 |
| - private string _upstreamHost; |
16 |
| - private List<DownstreamRoute> _downstreamRoutes; |
17 |
| - private List<AggregateRouteConfig> _downstreamRoutesConfig; |
18 |
| - private string _aggregator; |
19 |
| - |
20 |
| - public RouteBuilder() |
21 |
| - { |
22 |
| - _downstreamRoutes = new List<DownstreamRoute>(); |
23 |
| - _downstreamRoutesConfig = new List<AggregateRouteConfig>(); |
24 |
| - } |
25 |
| - |
26 |
| - public RouteBuilder WithDownstreamRoute(DownstreamRoute value) |
27 |
| - { |
28 |
| - _downstreamRoutes.Add(value); |
29 |
| - return this; |
30 |
| - } |
31 |
| - |
32 |
| - public RouteBuilder WithDownstreamRoutes(List<DownstreamRoute> value) |
33 |
| - { |
34 |
| - _downstreamRoutes = value; |
35 |
| - return this; |
36 |
| - } |
37 |
| - |
38 |
| - public RouteBuilder WithUpstreamHost(string upstreamAddresses) |
39 |
| - { |
40 |
| - _upstreamHost = upstreamAddresses; |
41 |
| - return this; |
42 |
| - } |
43 |
| - |
44 |
| - public RouteBuilder WithUpstreamPathTemplate(UpstreamPathTemplate input) |
45 |
| - { |
46 |
| - _upstreamTemplatePattern = input; |
47 |
| - return this; |
48 |
| - } |
49 |
| - |
50 |
| - public RouteBuilder WithUpstreamHttpMethod(List<string> input) |
51 |
| - { |
52 |
| - _upstreamHttpMethod = (input.Count == 0) ? new List<HttpMethod>() : input.Select(x => new HttpMethod(x.Trim())).ToList(); |
53 |
| - return this; |
54 |
| - } |
55 |
| - |
56 |
| - public RouteBuilder WithAggregateRouteConfig(List<AggregateRouteConfig> aggregateRouteConfigs) |
57 |
| - { |
58 |
| - _downstreamRoutesConfig = aggregateRouteConfigs; |
59 |
| - return this; |
60 |
| - } |
61 |
| - |
62 |
| - public RouteBuilder WithAggregator(string aggregator) |
63 |
| - { |
64 |
| - _aggregator = aggregator; |
65 |
| - return this; |
66 |
| - } |
67 |
| - |
68 |
| - public Route Build() |
69 |
| - { |
70 |
| - return new Route( |
71 |
| - _downstreamRoutes, |
72 |
| - _downstreamRoutesConfig, |
73 |
| - _upstreamHttpMethod, |
74 |
| - _upstreamTemplatePattern, |
75 |
| - _upstreamHost, |
76 |
| - _aggregator |
77 |
| - ); |
78 |
| - } |
79 |
| - } |
80 |
| -} |
| 8 | + |
| 9 | +namespace Ocelot.Configuration.Builder |
| 10 | +{ |
| 11 | + public class RouteBuilder |
| 12 | + { |
| 13 | + private UpstreamPathTemplate _upstreamTemplatePattern; |
| 14 | + private List<HttpMethod> _upstreamHttpMethod; |
| 15 | + private string _upstreamHost; |
| 16 | + private List<DownstreamRoute> _downstreamRoutes; |
| 17 | + private List<AggregateRouteConfig> _downstreamRoutesConfig; |
| 18 | + private string _aggregator; |
| 19 | + private UpstreamHeaderRoutingOptions _upstreamHeaderRoutingOptions; |
| 20 | + |
| 21 | + public RouteBuilder() |
| 22 | + { |
| 23 | + _downstreamRoutes = new List<DownstreamRoute>(); |
| 24 | + _downstreamRoutesConfig = new List<AggregateRouteConfig>(); |
| 25 | + } |
| 26 | + |
| 27 | + public RouteBuilder WithDownstreamRoute(DownstreamRoute value) |
| 28 | + { |
| 29 | + _downstreamRoutes.Add(value); |
| 30 | + return this; |
| 31 | + } |
| 32 | + |
| 33 | + public RouteBuilder WithDownstreamRoutes(List<DownstreamRoute> value) |
| 34 | + { |
| 35 | + _downstreamRoutes = value; |
| 36 | + return this; |
| 37 | + } |
| 38 | + |
| 39 | + public RouteBuilder WithUpstreamHost(string upstreamAddresses) |
| 40 | + { |
| 41 | + _upstreamHost = upstreamAddresses; |
| 42 | + return this; |
| 43 | + } |
| 44 | + |
| 45 | + public RouteBuilder WithUpstreamPathTemplate(UpstreamPathTemplate input) |
| 46 | + { |
| 47 | + _upstreamTemplatePattern = input; |
| 48 | + return this; |
| 49 | + } |
| 50 | + |
| 51 | + public RouteBuilder WithUpstreamHttpMethod(List<string> input) |
| 52 | + { |
| 53 | + _upstreamHttpMethod = (input.Count == 0) ? new List<HttpMethod>() : input.Select(x => new HttpMethod(x.Trim())).ToList(); |
| 54 | + return this; |
| 55 | + } |
| 56 | + |
| 57 | + public RouteBuilder WithAggregateRouteConfig(List<AggregateRouteConfig> aggregateRouteConfigs) |
| 58 | + { |
| 59 | + _downstreamRoutesConfig = aggregateRouteConfigs; |
| 60 | + return this; |
| 61 | + } |
| 62 | + |
| 63 | + public RouteBuilder WithAggregator(string aggregator) |
| 64 | + { |
| 65 | + _aggregator = aggregator; |
| 66 | + return this; |
| 67 | + } |
| 68 | + |
| 69 | + public RouteBuilder WithUpstreamHeaderRoutingOptions(UpstreamHeaderRoutingOptions routingOptions) |
| 70 | + { |
| 71 | + _upstreamHeaderRoutingOptions = routingOptions; |
| 72 | + return this; |
| 73 | + } |
| 74 | + |
| 75 | + public Route Build() |
| 76 | + { |
| 77 | + return new Route( |
| 78 | + _downstreamRoutes, |
| 79 | + _downstreamRoutesConfig, |
| 80 | + _upstreamHttpMethod, |
| 81 | + _upstreamTemplatePattern, |
| 82 | + _upstreamHost, |
| 83 | + _aggregator, |
| 84 | + _upstreamHeaderRoutingOptions); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments