code: public static <P extends ResponseBody> CompletableFuture<Void> sendResponse(
  			ChannelHandlerContext channelHandlerContext,
  			HttpRequest httpRequest,
  			P response,
  			HttpResponseStatus statusCode,
  			Map<String, String> headers) {
  		StringWriter sw = new StringWriter();
  		try {
  			mapper.writeValue(sw, response);
  		} catch (IOException ioe) {
  			LOG.error("Internal server error. Could not map response to JSON.", ioe);
  			return sendErrorResponse(
  				channelHandlerContext,
  				httpRequest,
  				new ErrorResponseBody("Internal server error. Could not map response to JSON."),
  				HttpResponseStatus.INTERNAL_SERVER_ERROR,
  				headers);
  		}
  		return sendResponse(
  			channelHandlerContext,
  			httpRequest,
  			sw.toString(),
  			statusCode,
  			headers);
  	}
docs: Sends the given response and status code to the given channel.
  
  @param channelHandlerContext identifying the open channel
  @param httpRequest originating http request
  @param response which should be sent
  @param statusCode of the message to send
  @param headers additional header values
  @param <P> type of the response