coRouter
Allow to create easily a WebFlux.fn RouterFunction with a Coroutines router Kotlin DSL.
Example:
@Configuration
class RouterConfiguration {
@Bean
fun mainRouter(userHandler: UserHandler) = coRouter {
accept(TEXT_HTML).nest {
(GET("/user/") or GET("/users/")).invoke(userHandler::findAllView)
GET("/users/{login}", userHandler::findViewById)
}
accept(APPLICATION_JSON).nest {
(GET("/api/user/") or GET("/api/users/")).invoke(userHandler::findAll)
POST("/api/users/", userHandler::create)
}
}
}
Content copied to clipboard
Author
Sebastien Deleuze
Since
5.2