private HttpResponse convertResponse(ServiceRequestContext ctx, @Nullable Object result) {
        if (result instanceof HttpResponse) {
            return (HttpResponse) result;
        }
        if (result instanceof AggregatedHttpResponse) {
            return ((AggregatedHttpResponse) result).toHttpResponse();
        }

        final ResponseHeaders headers;
        final HttpHeaders trailers;

        if (result instanceof ResponseEntity) {
            final ResponseEntity<?> responseEntity = (ResponseEntity<?>) result;
            headers = ResponseEntityUtil.buildResponseHeaders(ctx, responseEntity);
            result = responseEntity.hasContent() ? responseEntity.content() : null;
            trailers = responseEntity.trailers();
        } else if (result instanceof HttpResult) {
            final HttpResult<?> httpResult = (HttpResult<?>) result;
            headers = HttpResultUtil.buildResponseHeaders(ctx, httpResult);
            result = httpResult.content();
            trailers = httpResult.trailers();
        } else {
            headers = buildResponseHeaders(ctx);
            trailers = HttpHeaders.of();
        }

        return convertResponseInternal(ctx, headers, result, trailers);
    }
Converts the specified {@code result} to an {@link HttpResponse}.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/DefaultAnnotatedService.java