23
23
import java .util .Map ;
24
24
25
25
import org .springframework .boot .context .properties .ConfigurationProperties ;
26
+ import org .springframework .boot .context .properties .DeprecatedConfigurationProperty ;
27
+ import org .springframework .boot .context .properties .PropertyMapper ;
26
28
import org .springframework .core .Ordered ;
27
29
import org .springframework .http .HttpHeaders ;
28
30
import org .springframework .util .ObjectUtils ;
29
31
import org .springframework .util .StringUtils ;
30
32
import org .springframework .web .servlet .function .ServerRequest ;
31
33
34
+ import static org .springframework .cloud .gateway .server .mvc .filter .XForwardedRequestHeadersFilterProperties .PREFIX ;
35
+
32
36
@ ConfigurationProperties ("spring.cloud.gateway.x-forwarded" )
33
37
public class XForwardedRequestHeadersFilter implements HttpHeadersFilter .RequestHttpHeadersFilter , Ordered {
34
38
@@ -95,55 +99,97 @@ public class XForwardedRequestHeadersFilter implements HttpHeadersFilter.Request
95
99
/** If appending X-Forwarded-Prefix as a list is enabled. */
96
100
private boolean prefixAppend = true ;
97
101
102
+ @ Deprecated
103
+ public XForwardedRequestHeadersFilter () {
104
+ this (new XForwardedRequestHeadersFilterProperties ());
105
+ }
106
+
107
+ public XForwardedRequestHeadersFilter (XForwardedRequestHeadersFilterProperties props ) {
108
+ // TODO: remove individual properties in 4.2.0
109
+ // this.properties = properties;
110
+ PropertyMapper map = PropertyMapper .get ();
111
+ map .from (props ::getOrder ).to (this ::setOrder );
112
+ map .from (props ::isEnabled ).to (this ::setEnabled );
113
+ map .from (props ::isForEnabled ).to (this ::setForEnabled );
114
+ map .from (props ::isHostEnabled ).to (this ::setHostEnabled );
115
+ map .from (props ::isPortEnabled ).to (this ::setPortEnabled );
116
+ map .from (props ::isProtoEnabled ).to (this ::setProtoEnabled );
117
+ map .from (props ::isPrefixEnabled ).to (this ::setPrefixEnabled );
118
+ map .from (props ::isForAppend ).to (this ::setForAppend );
119
+ map .from (props ::isHostAppend ).to (this ::setHostAppend );
120
+ map .from (props ::isPortAppend ).to (this ::setPortAppend );
121
+ map .from (props ::isProtoAppend ).to (this ::setProtoAppend );
122
+ map .from (props ::isPrefixAppend ).to (this ::setPrefixAppend );
123
+ }
124
+
125
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".order" )
98
126
@ Override
99
127
public int getOrder () {
100
128
return this .order ;
101
129
}
102
130
131
+ @ Deprecated
103
132
public void setOrder (int order ) {
104
133
this .order = order ;
105
134
}
106
135
136
+ @ Deprecated
137
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".enabled" )
107
138
public boolean isEnabled () {
108
139
return enabled ;
109
140
}
110
141
142
+ @ Deprecated
111
143
public void setEnabled (boolean enabled ) {
112
144
this .enabled = enabled ;
113
145
}
114
146
147
+ @ Deprecated
148
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".for-enabled" )
115
149
public boolean isForEnabled () {
116
150
return forEnabled ;
117
151
}
118
152
153
+ @ Deprecated
119
154
public void setForEnabled (boolean forEnabled ) {
120
155
this .forEnabled = forEnabled ;
121
156
}
122
157
158
+ @ Deprecated
159
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".host-enabled" )
123
160
public boolean isHostEnabled () {
124
161
return hostEnabled ;
125
162
}
126
163
164
+ @ Deprecated
127
165
public void setHostEnabled (boolean hostEnabled ) {
128
166
this .hostEnabled = hostEnabled ;
129
167
}
130
168
169
+ @ Deprecated
170
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".port-enabled" )
131
171
public boolean isPortEnabled () {
132
172
return portEnabled ;
133
173
}
134
174
175
+ @ Deprecated
135
176
public void setPortEnabled (boolean portEnabled ) {
136
177
this .portEnabled = portEnabled ;
137
178
}
138
179
180
+ @ Deprecated
181
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".proto-enabled" )
139
182
public boolean isProtoEnabled () {
140
183
return protoEnabled ;
141
184
}
142
185
186
+ @ Deprecated
143
187
public void setProtoEnabled (boolean protoEnabled ) {
144
188
this .protoEnabled = protoEnabled ;
145
189
}
146
190
191
+ @ Deprecated
192
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".prefix-enabled" )
147
193
public boolean isPrefixEnabled () {
148
194
return prefixEnabled ;
149
195
}
@@ -152,30 +198,41 @@ public void setPrefixEnabled(boolean prefixEnabled) {
152
198
this .prefixEnabled = prefixEnabled ;
153
199
}
154
200
201
+ @ Deprecated
202
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".for-append" )
155
203
public boolean isForAppend () {
156
204
return forAppend ;
157
205
}
158
206
207
+ @ Deprecated
159
208
public void setForAppend (boolean forAppend ) {
160
209
this .forAppend = forAppend ;
161
210
}
162
211
212
+ @ Deprecated
213
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".host-append" )
163
214
public boolean isHostAppend () {
164
215
return hostAppend ;
165
216
}
166
217
218
+ @ Deprecated
167
219
public void setHostAppend (boolean hostAppend ) {
168
220
this .hostAppend = hostAppend ;
169
221
}
170
222
223
+ @ Deprecated
224
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".port-append" )
171
225
public boolean isPortAppend () {
172
226
return portAppend ;
173
227
}
174
228
229
+ @ Deprecated
175
230
public void setPortAppend (boolean portAppend ) {
176
231
this .portAppend = portAppend ;
177
232
}
178
233
234
+ @ Deprecated
235
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".proto-append" )
179
236
public boolean isProtoAppend () {
180
237
return protoAppend ;
181
238
}
@@ -184,10 +241,13 @@ public void setProtoAppend(boolean protoAppend) {
184
241
this .protoAppend = protoAppend ;
185
242
}
186
243
244
+ @ Deprecated
245
+ @ DeprecatedConfigurationProperty (replacement = PREFIX + ".prefix-append" )
187
246
public boolean isPrefixAppend () {
188
247
return prefixAppend ;
189
248
}
190
249
250
+ @ Deprecated
191
251
public void setPrefixAppend (boolean prefixAppend ) {
192
252
this .prefixAppend = prefixAppend ;
193
253
}
0 commit comments