@Override
    public HttpResponse convertResponse(ServiceRequestContext ctx,
                                        ResponseHeaders headers,
                                        @Nullable Object result,
                                        HttpHeaders trailers) throws Exception {
        if (result instanceof Observable) {
            return responseConverter.convertResponse(
                    ctx, headers, ((Observable<?>) result).toFlowable(BackpressureStrategy.BUFFER), trailers);
        }

        if (result instanceof Maybe) {
            final CompletableFuture<HttpResponse> future = new CompletableFuture<>();
            final Disposable disposable = ((Maybe<?>) result).subscribe(
                    o -> future.complete(onSuccess(ctx, headers, o, trailers)),
                    cause -> future.complete(onError(ctx, cause)),
                    () -> future.complete(onSuccess(ctx, headers, null, trailers)));
            return respond(future, disposable);
        }

        if (result instanceof Single) {
            final CompletableFuture<HttpResponse> future = new CompletableFuture<>();
            final Disposable disposable = ((Single<?>) result).subscribe(
                    o -> future.complete(onSuccess(ctx, headers, o, trailers)),
                    cause -> future.complete(onError(ctx, cause)));
            return respond(future, disposable);
        }

        if (result instanceof Completable) {
            final CompletableFuture<HttpResponse> future = new CompletableFuture<>();
            final Disposable disposable = ((Completable) result).subscribe(
                    () -> future.complete(onSuccess(ctx, headers, null, trailers)),
                    cause -> future.complete(onError(ctx, cause)));
            return respond(future, disposable);
        }

        return ResponseConverterFunction.fallthrough();
    }
Creates a new {@link ResponseConverterFunction} instance.

@param responseConverter the function which converts an object with the configured
                         {@link ResponseConverterFunction}
rxjava2/src/main/java/com/linecorp/armeria/server/rxjava2/ObservableResponseConverterFunction.java