jsonapi-converter
jsonapi-converter copied to clipboard
Does the library support Javas webclient and the reactor implementation?
I see there is a a plugin for Okhttp3. Was wondering if there will be support for the the reactive webclient
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
}
I have no plans to add reactive-webclient support.