@Nullable
    private static Function<AggregatedHttpResponse, AggregatedHttpResponse> generateResponseConverter(
            TranscodingSpec spec) {
        // Ignore the spec if the method is HttpBody. The response body is already in the correct format.
        if (HttpBody.getDescriptor().equals(spec.methodDescriptor.getOutputType())) {
            return httpResponse -> {
                final HttpData data = httpResponse.content();
                final JsonNode jsonNode = extractHttpBody(data);

                // Failed to parse the JSON body, return the original response.
                if (jsonNode == null) {
                    return httpResponse;
                }

                PooledObjects.close(data);

                // The data field is base64 encoded.
                // https://protobuf.dev/programming-guides/proto3/#json
                final String httpBody = jsonNode.get("data").asText();
                final byte[] httpBodyBytes = Base64.getDecoder().decode(httpBody);

                final ResponseHeaders newHeaders = httpResponse.headers().withMutations(builder -> {
                    final JsonNode contentType = jsonNode.get("contentType");

                    if (contentType != null && contentType.isTextual()) {
                        builder.set(HttpHeaderNames.CONTENT_TYPE, contentType.textValue());
                    } else {
                        builder.remove(HttpHeaderNames.CONTENT_TYPE);
                    }
                });

                return AggregatedHttpResponse.of(newHeaders, HttpData.wrap(httpBodyBytes));
            };
        }

        @Nullable
        final String responseBody = spec.responseBody;
        if (responseBody == null) {
            return null;
        }

        return httpResponse -> {
            try (HttpData data = httpResponse.content()) {
                final HttpData convertedData = convertHttpDataForResponseBody(responseBody, data);
                return AggregatedHttpResponse.of(httpResponse.headers(), convertedData);
            }
        };
    }
Creates a new {@link GrpcService} instance from the given {@code delegate}. If it is possible
to support HTTP/JSON to gRPC transcoding, a new {@link HttpJsonTranscodingService} instance
would be returned. Otherwise, the {@code delegate} would be returned.
grpc/src/main/java/com/linecorp/armeria/server/grpc/HttpJsonTranscodingService.java