vertx/src/main/java/eu/internetofus/common/vertx/ComponentClient.java
/**
   * Create a handler that extract the model from a {@link HttpResponse}.
   *
   * @param extractor function to obtain the content of the response.
   * @param promise   to inform of the model.
   * @param actionId  identifier of the HTTP requests.
   *
   * @param <T>       type of model to extract.
   *
   * @return the handler for the response object.
   */
Create a handler that extract the model from a  HttpResponse.
@param extractor function to obtain the content of the response.
@param promise   to inform of the model.
@param actionId  identifier of the HTTP requests.

@param        type of model to extract.

@return the handler for the response object.
Create a handler that extract the model from a HttpResponse . @param extractor function to obtain the content of the response . @param promise to inform of the model . @param actionId identifier of the HTTP requests . @param type of model to extract . @return the handler for the response object .
protected <T> Handler<HttpResponse<Buffer>> createHandlerThatExtractBodyFromSuccessResponse(
      final Function<HttpResponse<Buffer>, T> extractor, final Promise<T> promise, final String actionId) {
    return response -> {
      final var code = response.statusCode();
      if (Status.NO_CONTENT.getStatusCode() == code) {
        Logger.trace("{} SUCCESS with code {}", actionId, code);
        promise.complete();
      } else if (Status.Family.familyOf(code) == Status.Family.SUCCESSFUL) {
        try {
          final var model = extractor.apply(response);
          Logger.trace("{} SUCCESS with code {} and content {}", actionId, code, model);
          promise.complete(model);
        } catch (final Throwable cause) {
          Logger.trace(cause, "{} FAILED with code {} and unexpected content {}", () -> actionId, () -> code,
              () -> response.bodyAsString());
          promise.fail(cause);
        }
      } else {
        Logger.trace("{} FAILED with code {} and content {}", () -> actionId, () -> code,
            () -> response.bodyAsString());
        final var cause = this.toServiceException(response);
        promise.fail(cause);
      }
    };
  }
protected < T > Handler < HttpResponse < Buffer > > createHandlerThatExtractBodyFromSuccessResponse ( final Function < HttpResponse < Buffer > , T > extractor , final Promise < T > promise , final String actionId ) { return response -> { final var code = response . statusCode ( ) ; if ( Status . NO_CONTENT . getStatusCode ( ) == code ) { Logger . trace ( "{} SUCCESS with code {}" , actionId , code ) ; promise . complete ( ) ; } else if ( Status . Family . familyOf ( code ) == Status . Family . SUCCESSFUL ) { try { final var model = extractor . apply ( response ) ; Logger . trace ( "{} SUCCESS with code {} and content {}" , actionId , code , model ) ; promise . complete ( model ) ; } catch ( final Throwable cause ) { Logger . trace ( cause , "{} FAILED with code {} and unexpected content {}" , ( ) -> actionId , ( ) -> code , ( ) -> response . bodyAsString ( ) ) ; promise . fail ( cause ) ; } } else { Logger . trace ( "{} FAILED with code {} and content {}" , ( ) -> actionId , ( ) -> code , ( ) -> response . bodyAsString ( ) ) ; final var cause = this . toServiceException ( response ) ; promise . fail ( cause ) ; } } ; }
Create a handler that extract the model from a {@link HttpResponse}.
Create a handler that extract the model from a { @link HttpResponse } .