File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
app/src/main/java/com/example/demo Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,13 @@ public static void main(String[] args) {
2020
2121 @ GetMapping
2222 public Mono <String > index () {
23- return webClient .get ().uri ("http://k8s-workshop-name-service" ).exchange ().flatMap (clientResponse -> {
24- String host = clientResponse .headers ().asHttpHeaders ().get ("k8s-host" ).get (0 );
25- return clientResponse .bodyToMono (String .class ).flatMap (name -> Mono .just ("Hello " + name + " from " + host ));
26- });
23+ return webClient .get ().uri ("http://k8s-workshop-name-service" )
24+ .retrieve ()
25+ .toEntity (String .class )
26+ .map (entity -> {
27+ String host = entity .getHeaders ().get ("k8s-host" ).get (0 );
28+ return "Hello " + entity .getBody () + " from " + host ;
29+ });
30+
2731 }
2832}
You can’t perform that action at this time.
0 commit comments