title: How to perform consecutive web requests based on another request in one Mono in Spring WebFlux?
body: <p>I want to do the following via Spring WebFlux and a given REST-API:</p>
  
  <ol>
  <li>Retrieve a list of file names (GET /files)</li>
  <li>Delete each retrieved file (DELETE /files/local/{file name} for each)</li>
  </ol>
  
  <p>The problem is that I cannot combine both actions to "one" Mono instance. My current implementation is insufficient, because it blocks the Mono instances to execute the api calls immediately insteaf of performing them reactive.</p>
  
  <p>My non reactive implementation:</p>
  
  <pre><code>public Mono cleanUpUploadedFiles() {    
      WebClient webClient = this.getWebClient();
  
      // get all files / directories
      Mono&lt;FilesOverview&gt; filesOverviewMono = this.getResource("/files", FilesOverview.class);
      FilesOverview filesOverview = filesOverviewMono.block(); // TODO: prevent blocking mono
  
      // delete file / directory one by one
      for (FileOverview file : filesOverview.getFiles()) {
          ClientResponse clientResponse;
  
          clientResponse = webClient
                  .delete()
                  .uri(String.format("/files/local/%s", file.getName()))
                  .exchange()
                  .block(); // TODO: prevent blocking mono
          if (clientResponse == null) {
              return Mono.error(new MyException(String.format("could not execute rest call to delete uploaded files with uuid %s", file.getName())));
          }
  
          HttpStatus clientResponseStatusCode = clientResponse.statusCode();
          if (clientResponseStatusCode.isError()) {
              return Mono.error(new MyException(String.format("cannot delete uploaded files with uuid %s", file.getName())));
          }
      }
  
      return Mono.empty(); // TODO: return Mono instance performing everything reactive without blocking
  }
  </code></pre>
  
  <p>How to perform the consecutive web requests in one Mono instance reactive?</p>