wsclient/src/main/kotlin/com/cubetiqs/wsclient/WsClientApplication.kt

27 lines
909 B
Kotlin
Raw Normal View History

package com.cubetiqs.wsclient
2020-07-12 12:33:48 +07:00
import org.springframework.beans.factory.annotation.Autowired
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
@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)
}
}