-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
FileRoute.cs
110 lines (106 loc) · 5.65 KB
/
FileRoute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
namespace Ocelot.Configuration.File
{
public class FileRoute : IRoute, ICloneable
{
public FileRoute()
{
AddClaimsToRequest = new Dictionary<string, string>();
AddHeadersToRequest = new Dictionary<string, string>();
AddQueriesToRequest = new Dictionary<string, string>();
AuthenticationOptions = new FileAuthenticationOptions();
ChangeDownstreamPathTemplate = new Dictionary<string, string>();
DelegatingHandlers = new List<string>();
DownstreamHeaderTransform = new Dictionary<string, string>();
DownstreamHostAndPorts = new List<FileHostAndPort>();
FileCacheOptions = new FileCacheOptions();
HttpHandlerOptions = new FileHttpHandlerOptions();
LoadBalancerOptions = new FileLoadBalancerOptions();
Priority = 1;
QoSOptions = new FileQoSOptions();
RateLimitOptions = new FileRateLimitRule();
RouteClaimsRequirement = new Dictionary<string, string>();
SecurityOptions = new FileSecurityOptions();
UpstreamHeaderTransform = new Dictionary<string, string>();
UpstreamHttpMethod = new List<string>();
}
public FileRoute(FileRoute from)
{
DeepCopy(from, this);
}
public Dictionary<string, string> AddClaimsToRequest { get; set; }
public Dictionary<string, string> AddHeadersToRequest { get; set; }
public Dictionary<string, string> AddQueriesToRequest { get; set; }
public FileAuthenticationOptions AuthenticationOptions { get; set; }
public Dictionary<string, string> ChangeDownstreamPathTemplate { get; set; }
public bool DangerousAcceptAnyServerCertificateValidator { get; set; }
public List<string> DelegatingHandlers { get; set; }
public Dictionary<string, string> DownstreamHeaderTransform { get; set; }
public List<FileHostAndPort> DownstreamHostAndPorts { get; set; }
public string DownstreamHttpMethod { get; set; }
public string DownstreamHttpVersion { get; set; }
public string DownstreamPathTemplate { get; set; }
public string DownstreamScheme { get; set; }
public FileCacheOptions FileCacheOptions { get; set; }
public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
public string Key { get; set; }
public FileLoadBalancerOptions LoadBalancerOptions { get; set; }
public int Priority { get; set; }
public FileQoSOptions QoSOptions { get; set; }
public FileRateLimitRule RateLimitOptions { get; set; }
public string RequestIdKey { get; set; }
public Dictionary<string, string> RouteClaimsRequirement { get; set; }
public bool RouteIsCaseSensitive { get; set; }
public FileSecurityOptions SecurityOptions { get; set; }
public string ServiceName { get; set; }
public string ServiceNamespace { get; set; }
public int Timeout { get; set; }
public Dictionary<string, string> UpstreamHeaderTransform { get; set; }
public string UpstreamHost { get; set; }
public List<string> UpstreamHttpMethod { get; set; }
public string UpstreamPathTemplate { get; set; }
/// <summary>
/// Clones this object by making a deep copy.
/// </summary>
/// <returns>A <see cref="FileRoute"/> deeply copied object.</returns>
public object Clone()
{
var other = (FileRoute)MemberwiseClone();
DeepCopy(this, other);
return other;
}
public static void DeepCopy(FileRoute from, FileRoute to)
{
to.AddClaimsToRequest = new(from.AddClaimsToRequest);
to.AddHeadersToRequest = new(from.AddHeadersToRequest);
to.AddQueriesToRequest = new(from.AddQueriesToRequest);
to.AuthenticationOptions = new(from.AuthenticationOptions);
to.ChangeDownstreamPathTemplate = new(from.ChangeDownstreamPathTemplate);
to.DangerousAcceptAnyServerCertificateValidator = from.DangerousAcceptAnyServerCertificateValidator;
to.DelegatingHandlers = new(from.DelegatingHandlers);
to.DownstreamHeaderTransform = new(from.DownstreamHeaderTransform);
to.DownstreamHostAndPorts = from.DownstreamHostAndPorts.Select(x => new FileHostAndPort(x)).ToList();
to.DownstreamHttpMethod = from.DownstreamHttpMethod;
to.DownstreamHttpVersion = from.DownstreamHttpVersion;
to.DownstreamPathTemplate = from.DownstreamPathTemplate;
to.DownstreamScheme = from.DownstreamScheme;
to.FileCacheOptions = new(from.FileCacheOptions);
to.HttpHandlerOptions = new(from.HttpHandlerOptions);
to.Key = from.Key;
to.LoadBalancerOptions = new(from.LoadBalancerOptions);
to.Priority = from.Priority;
to.QoSOptions = new(from.QoSOptions);
to.RateLimitOptions = new(from.RateLimitOptions);
to.RequestIdKey = from.RequestIdKey;
to.RouteClaimsRequirement = new(from.RouteClaimsRequirement);
to.RouteIsCaseSensitive = from.RouteIsCaseSensitive;
to.SecurityOptions = new(from.SecurityOptions);
to.ServiceName = from.ServiceName;
to.ServiceNamespace = from.ServiceNamespace;
to.Timeout = from.Timeout;
to.UpstreamHeaderTransform = new(from.UpstreamHeaderTransform);
to.UpstreamHost = from.UpstreamHost;
to.UpstreamHttpMethod = new(from.UpstreamHttpMethod);
to.UpstreamPathTemplate = from.UpstreamPathTemplate;
}
}
}