wsclient/src/main/kotlin/com/cubetiqs/wsclient/WebClientStockClient.kt
2020-07-11 21:19:29 +07:00

16 lines
539 B
Kotlin

package com.cubetiqs.wsclient
import org.springframework.web.reactive.function.client.WebClient
import reactor.core.publisher.Flux
class WebClientStockClient(val webClient: WebClient) : StockClient {
override fun priceFor(symbol: String): Flux<StockPrice> {
return webClient.get()
.uri("http://localhost:8080/stocks/{symbol}", symbol)
.retrieve()
.bodyToFlux(StockPrice::class.java)
.doOnError {
println(it.message)
}
}
}