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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
use std::{collections::BTreeMap, ops::Not};
use super::Authorization;
use crate::deserializers::comma_separated_string;
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct Kong {
pub name: String,
pub upstream_url: String,
#[serde(skip_serializing_if = "Not::not")]
pub internal: bool,
#[serde(skip_serializing_if = "Not::not")]
pub publiclyAccessible: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub authorization: Option<Authorization>,
#[serde(skip_serializing_if = "Option::is_none")]
pub uris: Option<String>,
#[serde(
skip_serializing_if = "Vec::is_empty",
deserialize_with = "comma_separated_string"
)]
pub hosts: Vec<String>,
pub auth: Option<Authentication>,
pub strip_uri: bool,
#[serde(default = "preserve_host_default")]
pub preserve_host: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub cors: Option<Cors>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub additional_internal_ips: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub babylon_auth_header: Option<BabylonAuthHeader>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upstream_connect_timeout: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upstream_send_timeout: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upstream_read_timeout: Option<u32>,
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub add_headers: BTreeMap<String, String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub upstream_service: Option<String>,
pub babylon_request_id: bool,
pub w3c_trace_context: bool,
pub ip_rate_limits: Option<KongRateLimit>,
pub user_rate_limits: Option<KongRateLimit>,
}
fn preserve_host_default() -> bool {
true
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct Cors {
pub credentials: bool,
pub enabled: bool,
pub exposed_headers: String,
pub headers: String,
pub max_age: String,
pub methods: String,
pub origin: String,
pub preflight_continue: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "filesystem", serde(deny_unknown_fields))]
pub struct BabylonAuthHeader {
pub auth_service: String,
pub cache_timeout_sec: u32,
pub enabled: bool,
pub http_timeout_msec: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct KongRateLimit {
pub per_second: Option<u32>,
pub per_minute: Option<u32>,
pub per_hour: Option<u32>,
pub per_day: Option<u32>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")]
pub enum Authentication {
None,
Jwt,
}