Make GET /{function}/{value} single valued (Mono)
When the user has sent us a single value, we can make the signature of the handler and the format of the HTTP response much more natural if it is single valued too (i.e. a Mono).
This commit is contained in:
@@ -160,6 +160,14 @@ public class RestApplicationTests {
|
||||
assertThat(rest.getForObject("/wrap/123", String.class)).isEqualTo("..123..");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertGetJson() throws Exception {
|
||||
assertThat(rest
|
||||
.exchange(RequestEntity.get(new URI("/entity/321"))
|
||||
.accept(MediaType.APPLICATION_JSON).build(), String.class)
|
||||
.getBody()).isEqualTo("{\"value\":321}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uppercaseJsonArray() throws Exception {
|
||||
assertThat(rest.exchange(
|
||||
@@ -208,6 +216,12 @@ public class RestApplicationTests {
|
||||
return flux -> flux.log().map(value -> ".." + value + "..");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Integer>, Flux<Map<String, Object>>> entity() {
|
||||
return flux -> flux.log()
|
||||
.map(value -> Collections.singletonMap("value", value));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<HashMap<String, String>>, Flux<Map<String, String>>> maps() {
|
||||
return flux -> flux.map(value -> {
|
||||
|
||||
Reference in New Issue
Block a user