@@ -62,7 +62,7 @@ public final class FunctionWebUtils {
|
||||
String name = path;
|
||||
String[] splitPath = path.split("/");
|
||||
Function<Object, Object> function = null;
|
||||
for (int i = 0; i < splitPath.length || function != null; i++) {
|
||||
for (int i = 0; i < splitPath.length && functionForGet == null; i++) {
|
||||
String element = splitPath[i];
|
||||
if (builder.length() > 0) {
|
||||
builder.append("/");
|
||||
|
||||
@@ -244,6 +244,14 @@ public class HttpGetIntegrationTests {
|
||||
.getBody()).isEqualTo("{\"value\":321}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compose() throws Exception {
|
||||
ResponseEntity<String> result = this.rest.exchange(RequestEntity
|
||||
.get(new URI("/concat,reverse/foo")).accept(MediaType.TEXT_PLAIN).build(),
|
||||
String.class);
|
||||
assertThat(result.getBody()).isEqualTo("oofoof");
|
||||
}
|
||||
|
||||
private String sse(String... values) {
|
||||
return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
|
||||
}
|
||||
@@ -259,6 +267,17 @@ public class HttpGetIntegrationTests {
|
||||
args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> concat() {
|
||||
return flux -> flux.map(v -> v + v);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> reverse() {
|
||||
return flux -> flux.log()
|
||||
.map(value -> new StringBuilder(value.trim()).reverse().toString());
|
||||
}
|
||||
|
||||
@Bean({ "uppercase", "post/more" })
|
||||
public Function<Flux<String>, Flux<String>> uppercase() {
|
||||
return flux -> flux.log()
|
||||
|
||||
@@ -237,6 +237,14 @@ public class HttpGetIntegrationTests {
|
||||
.getBody()).isEqualTo("{\"value\":321}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compose() throws Exception {
|
||||
ResponseEntity<String> result = this.rest.exchange(RequestEntity
|
||||
.get(new URI("/concat,reverse/foo")).accept(MediaType.TEXT_PLAIN).build(),
|
||||
String.class);
|
||||
assertThat(result.getBody()).isEqualTo("oofoof");
|
||||
}
|
||||
|
||||
private String sse(String... values) {
|
||||
return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
|
||||
}
|
||||
@@ -252,6 +260,17 @@ public class HttpGetIntegrationTests {
|
||||
args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> concat() {
|
||||
return flux -> flux.map(v -> v + v);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> reverse() {
|
||||
return flux -> flux.log()
|
||||
.map(value -> new StringBuilder(value.trim()).reverse().toString());
|
||||
}
|
||||
|
||||
@Bean({ "uppercase", "post/more" })
|
||||
public Function<Flux<String>, Flux<String>> uppercase() {
|
||||
return flux -> flux.log()
|
||||
|
||||
Reference in New Issue
Block a user