vertx/src/main/java/eu/internetofus/common/vertx/ServiceResponseHandlers.java
/**
   * Handle with a response with the specified status and content.
   *
   * @param resultHandler handler that will manage the response.
   * @param status        HTTP status code.
   * @param model         to send.
   */
Handle with a response with the specified status and content.
@param resultHandler handler that will manage the response.
@param status        HTTP status code.
@param model         to send.
Handle with a response with the specified status and content . @param resultHandler handler that will manage the response . @param status HTTP status code . @param model to send .
static void responseWith(final Handler<AsyncResult<ServiceResponse>> resultHandler, final Status status,
      final Object model) {
    Buffer buffer;
    if (model instanceof Model) {
      buffer = ((Model) model).toBufferWithEmptyValues();
    } else if (model instanceof JsonObject) {
      buffer = ((JsonObject) model).toBuffer();
    } else {
      buffer = Buffer.buffer(String.valueOf(model));
    }
    Logger.trace("Response {} with {}", status, model);
    resultHandler.handle(Future.succeededFuture(new ServiceResponse().setStatusCode(status.getStatusCode())
        .putHeader(HttpHeaders.CONTENT_TYPE.toString(), MediaType.APPLICATION_JSON).setPayload(buffer)));
  }
static void responseWith ( final Handler < AsyncResult < ServiceResponse > > resultHandler , final Status status , final Object model ) { Buffer buffer ; if ( model instanceof Model ) { buffer = ( ( Model ) model ) . toBufferWithEmptyValues ( ) ; } else if ( model instanceof JsonObject ) { buffer = ( ( JsonObject ) model ) . toBuffer ( ) ; } else { buffer = Buffer . buffer ( String . valueOf ( model ) ) ; } Logger . trace ( "Response {} with {}" , status , model ) ; resultHandler . handle ( Future . succeededFuture ( new ServiceResponse ( ) . setStatusCode ( status . getStatusCode ( ) ) . putHeader ( HttpHeaders . CONTENT_TYPE . toString ( ) , MediaType . APPLICATION_JSON ) . setPayload ( buffer ) ) ) ; }
Handle with a response with the specified status and content.
Handle with a response with the specified status and content .