jsonapi-converter icon indicating copy to clipboard operation
jsonapi-converter copied to clipboard

Does the library support Javas webclient and the reactor implementation?

Open moizalidv opened this issue 3 years ago • 1 comments

I see there is a a plugin for Okhttp3. Was wondering if there will be support for the the reactive webclient

moizalidv avatar May 30 '21 11:05 moizalidv

I have been able to make it work:

fun <T> WebClient.fetchJsonApiSingleObject(
    resourceConverter: ResourceConverter,
    modelImplementation: Class<T>,
    errorHandler: ((ClientResponse) -> Mono<Throwable>)? = null,
    uriBuilderFunction: (UriBuilder) -> URI
): Mono<T> =
    get()
        .uri(uriBuilderFunction)
        .retrieve()
        .onStatus(HttpStatus::isError) { clientResponse: ClientResponse ->
            errorHandler?.invoke(clientResponse) ?: handleErrors(clientResponse)
        }
        .bodyToMono(ByteArray::class.java)
        .map {
            resourceConverter.readDocument(it, modelImplementation).get()  as T
        }

moizalidv avatar May 30 '21 17:05 moizalidv

I have no plans to add reactive-webclient support.

jasminb avatar Jul 31 '24 20:07 jasminb