title: How to compile answer from multiple requests with Spring WebClient
body: <p>I want to make a proxy controller. I get a single HTTP request and I need to proxy it to other services, then compile answers from responses into one and send it back. If one response contains an exception, ResponseEntity shouldn't be with code 200(OK). </p>
  
  <pre><code>@PostMapping("**")
  public ResponseEntity&lt;String&gt; processIn(@RequestHeader HttpHeaders headers, @RequestBody String body,  ServerHttpRequest request) {
  
      Mono&lt;String&gt; firstAnswer = sendRequest(headers, body, "https://localhost:1443");
      Mono&lt;String&gt; secondAnswer = sendRequest(headers, body, "http://localhost:8080");
  
      return ResponseEntity.ok().body(format("1: %s \n 2: %s", firstAnswer, secondAnswer));
  }
  
  private Mono&lt;String&gt; sendRequest(HttpHeaders headers, String body, String url) {
          return webClient.post()
                  .uri(new URI(url))
                  .headers(httpHeaders -&gt; new HttpHeaders(headers))
                  .bodyValue(body)
                  .retrieve()
                  .bodyToMono(String.class)
                  .doOnNext(ans -&gt; log.info("&gt;&gt;&gt;&gt;request to {} : {}", url, ans))
                  .doOnError(err -&gt; log.error("&gt;&gt;&gt;&gt;error sending to {}", url));
      }
  </code></pre>