Add HttpRequestValues.Processor

Closes gh-34699
This commit is contained in:
rstoyanchev
2025-04-15 17:17:13 +01:00
parent 88e773ae24
commit 40853825dc
5 changed files with 92 additions and 8 deletions

View File

@@ -198,12 +198,12 @@ class HttpServiceMethodTests {
@Test
void typeAndMethodAnnotatedService() {
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder()
.exchangeAdapter(this.client)
.embeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value))
.build();
MethodLevelAnnotatedService service = proxyFactory.createClient(TypeAndMethodLevelAnnotatedService.class);
MethodLevelAnnotatedService service = HttpServiceProxyFactory.builder()
.exchangeAdapter(this.client)
.embeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value))
.build()
.createClient(TypeAndMethodLevelAnnotatedService.class);
service.performGet();
@@ -222,6 +222,19 @@ class HttpServiceMethodTests {
assertThat(requestValues.getHeaders().getAccept()).containsOnly(MediaType.APPLICATION_JSON);
}
@Test
void httpRequestValuesProcessor() {
HttpServiceProxyFactory.builder()
.exchangeAdapter(this.client)
.httpRequestValuesProcessor((m, a, builder) -> builder.addAttribute("foo", "a"))
.build()
.createClient(Service.class)
.execute();
assertThat(this.client.getRequestValues().getAttributes().get("foo")).isEqualTo("a");
}
@Test // gh-32049
void multipleAnnotationsAtClassLevel() {
Class<?> serviceInterface = MultipleClassLevelAnnotationsService.class;