OS
package com.example.kotlinreactiveweb
import org.springframework.boot.Banner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.core.io.ClassPathResource
import org.springframework.stereotype.Component
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.server.ServerRequest
import org.springframework.web.reactive.function.server.ServerResponse.ok
import org.springframework.web.reactive.function.server.router
@SpringBootApplication
class KotlinReactiveWebApplication {
@Bean
fun router(greetingHandler: GreetingHandler) = router {
GET("/hello", greetingHandler::hello)
}
}
@Component
class GreetingHandler {
fun hello(request: ServerRequest) = ok().body(
BodyInserters.fromObject("Hello, SpringBoot Kotlin WebFlux!"));
}
fun main(args: Array<String>) {
runApplication<KotlinReactiveWebApplication>(*args) {
setBannerMode(Banner.Mode.OFF)
}
}