@@ -58,15 +58,19 @@ public final class HttpServiceProxyFactory {
58
58
59
59
private final List <HttpServiceArgumentResolver > argumentResolvers ;
60
60
61
+ private final HttpRequestValues .Processor requestValuesProcessor ;
62
+
61
63
private final @ Nullable StringValueResolver embeddedValueResolver ;
62
64
63
65
64
66
private HttpServiceProxyFactory (
65
67
HttpExchangeAdapter exchangeAdapter , List <HttpServiceArgumentResolver > argumentResolvers ,
68
+ List <HttpRequestValues .Processor > requestValuesProcessor ,
66
69
@ Nullable StringValueResolver embeddedValueResolver ) {
67
70
68
71
this .exchangeAdapter = exchangeAdapter ;
69
72
this .argumentResolvers = argumentResolvers ;
73
+ this .requestValuesProcessor = new CompositeHttpRequestValuesProcessor (requestValuesProcessor );
70
74
this .embeddedValueResolver = embeddedValueResolver ;
71
75
}
72
76
@@ -97,7 +101,8 @@ private <S> HttpServiceMethod createHttpServiceMethod(Class<S> serviceType, Meth
97
101
"No argument resolvers: afterPropertiesSet was not called" );
98
102
99
103
return new HttpServiceMethod (
100
- method , serviceType , this .argumentResolvers , this .exchangeAdapter , this .embeddedValueResolver );
104
+ method , serviceType , this .argumentResolvers , this .requestValuesProcessor ,
105
+ this .exchangeAdapter , this .embeddedValueResolver );
101
106
}
102
107
103
108
@@ -126,6 +131,8 @@ public static final class Builder {
126
131
127
132
private final List <HttpServiceArgumentResolver > customArgumentResolvers = new ArrayList <>();
128
133
134
+ private final List <HttpRequestValues .Processor > requestValuesProcessors = new ArrayList <>();
135
+
129
136
private @ Nullable ConversionService conversionService ;
130
137
131
138
private @ Nullable StringValueResolver embeddedValueResolver ;
@@ -154,6 +161,18 @@ public Builder customArgumentResolver(HttpServiceArgumentResolver resolver) {
154
161
return this ;
155
162
}
156
163
164
+ /**
165
+ * Register an {@link HttpRequestValues} processor that can further
166
+ * customize request values based on the method and all arguments.
167
+ * @param processor the processor to add
168
+ * @return this same builder instance
169
+ * @since 7.0
170
+ */
171
+ public Builder httpRequestValuesProcessor (HttpRequestValues .Processor processor ) {
172
+ this .requestValuesProcessors .add (processor );
173
+ return this ;
174
+ }
175
+
157
176
/**
158
177
* Set the {@link ConversionService} to use where input values need to
159
178
* be formatted as Strings.
@@ -183,7 +202,8 @@ public HttpServiceProxyFactory build() {
183
202
Assert .notNull (this .exchangeAdapter , "HttpClientAdapter is required" );
184
203
185
204
return new HttpServiceProxyFactory (
186
- this .exchangeAdapter , initArgumentResolvers (), this .embeddedValueResolver );
205
+ this .exchangeAdapter , initArgumentResolvers (), this .requestValuesProcessors ,
206
+ this .embeddedValueResolver );
187
207
}
188
208
189
209
@ SuppressWarnings ({"DataFlowIssue" , "NullAway" })
@@ -251,7 +271,21 @@ private static Object[] resolveCoroutinesArguments(@Nullable Object[] args) {
251
271
System .arraycopy (args , 0 , functionArgs , 0 , args .length - 1 );
252
272
return functionArgs ;
253
273
}
274
+ }
275
+
276
+
277
+ /**
278
+ * Processor that delegates to a list of other processors.
279
+ */
280
+ private record CompositeHttpRequestValuesProcessor (List <HttpRequestValues .Processor > processors )
281
+ implements HttpRequestValues .Processor {
254
282
283
+ @ Override
284
+ public void process (Method method , @ Nullable Object [] arguments , HttpRequestValues .Builder builder ) {
285
+ for (HttpRequestValues .Processor processor : this .processors ) {
286
+ processor .process (method , arguments , builder );
287
+ }
288
+ }
255
289
}
256
290
257
291
}
0 commit comments