private void handleEngineResult(ApiRequest request, IEngineResult engineResult) {
        // Everything worked
        if (engineResult.isResponse() && responseIsNotClosed()) {
            ApiResponse response = engineResult.getApiResponse();

            setCorsHeadersForSwaggerUi(request, response);

            HttpApiFactory.buildResponse(vertxResponse, response, vertxRequest.version());

            if (!response.getHeaders().containsKey("Content-Length")) { //$NON-NLS-1$
                vertxResponse.setChunked(true);
            }

            engineResult.bodyHandler(buffer -> {
                vertxResponse.write((Buffer) buffer.getNativeBuffer());
            });

            engineResult.endHandler(end -> vertxResponse.end());
        } else { // Policy failure (i.e. denial - it's not an exception).
            log.debug(String.format("Failed with policy failure (denial): %s", engineResult.getPolicyFailure())); //$NON-NLS-1$
            handlePolicyFailure(request, engineResult.getPolicyFailure(), vertxResponse);
        }
    }
@author Marc Savy {@literal <msavy@redhat.com>}
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/http/HttpPolicyAdapter.java