2020-07-11 21:01:38 +07:00
|
|
|
package com.cubetiqs.wsclient
|
|
|
|
|
2020-07-12 12:33:48 +07:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
2020-07-11 21:01:38 +07:00
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
2020-07-12 12:33:48 +07:00
|
|
|
import org.springframework.boot.runApplication
|
|
|
|
import org.springframework.http.MediaType
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable
|
|
|
|
import org.springframework.web.bind.annotation.RestController
|
|
|
|
import reactor.core.publisher.Flux
|
2020-07-11 21:01:38 +07:00
|
|
|
|
|
|
|
@SpringBootApplication
|
2020-07-12 12:33:48 +07:00
|
|
|
class WsClientApplication
|
|
|
|
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
runApplication<WsClientApplication>(*args)
|
|
|
|
}
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
class RestController @Autowired constructor(
|
|
|
|
private val stockClient: StockClient
|
|
|
|
) {
|
|
|
|
@GetMapping("/{symbol}", produces = [MediaType.TEXT_EVENT_STREAM_VALUE])
|
|
|
|
fun getStockPrices(@PathVariable symbol: String): Flux<StockPrice> {
|
|
|
|
return stockClient.priceFor(symbol)
|
|
|
|
}
|
|
|
|
}
|