Fix call.
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.examples;
|
||||
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -52,9 +51,9 @@ public class GreetingController {
|
||||
*/
|
||||
@GetMapping("/greeting")
|
||||
public Mono<String> getGreeting(
|
||||
@RequestParam(value = "delay", defaultValue = "0") int delay) {
|
||||
return Mono
|
||||
.just(String.format("Hello from %s!", nameService.getName(delay)));
|
||||
@RequestParam(value = "delay", defaultValue = "0") int delay) {
|
||||
return nameService.getName(delay)
|
||||
.map(name -> String.format("Hello from %s!", name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.cloud.kubernetes.examples;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
@@ -37,10 +36,10 @@ public class NameService {
|
||||
webClient = webClientBuilder.build();
|
||||
}
|
||||
|
||||
public Mono<ClientResponse> getName(int delay) {
|
||||
public Mono<String> getName(int delay) {
|
||||
return webClient.get()
|
||||
.uri("http://name-service/name?delay=%d", delay)
|
||||
.exchange();
|
||||
.uri(String.format("http://name-service/name?delay=%d", delay)).retrieve()
|
||||
.bodyToMono(String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ public class NameController {
|
||||
*/
|
||||
@GetMapping("/name")
|
||||
public Mono<String> getName(
|
||||
@RequestParam(value = "delay", defaultValue = "0") int delayValue) {
|
||||
@RequestParam(value = "delay", defaultValue = "0") int delayValue) {
|
||||
LOG.info(String.format("Returning a name '%s' with a delay '%d'", hostName,
|
||||
delayValue));
|
||||
delayValue));
|
||||
delay(delayValue);
|
||||
return Mono.just(hostName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user