Update RouterFunctionExtensions documentation

This commit is contained in:
Sebastien Deleuze 2017-04-10 10:25:14 +02:00
parent 57f1f4cc98
commit 18d8876dc8
1 changed files with 11 additions and 15 deletions

View File

@ -22,29 +22,25 @@ import org.springframework.http.MediaType
import reactor.core.publisher.Mono
/**
* Provide a routing DSL for [RouterFunctions] and [RouterFunction] in order to be able to
* write idiomatic Kotlin code as below:
* Provide a [RouterFunction] Kotlin DSL in order to be able to write idiomatic Kotlin code as below:
*
* ```kotlin
*
* @Controller
* class FooController : RouterFunction<ServerResponse> {
* @Configuration
* class ApplicationRoutes(val userHandler: UserHandler) {
*
* override fun route(req: ServerRequest) = route(req) {
* accept(TEXT_HTML).apply {
* (GET("/user/") or GET("/users/")) { findAllView() }
* GET("/user/{login}", this@FooController::findViewById)
* @Bean
* fun mainRouter() = router {
* accept(TEXT_HTML).nest {
* (GET("/user/") or GET("/users/")).invoke(userHandler::findAllView)
* GET("/users/{login}", userHandler::findViewById)
* }
* accept(APPLICATION_JSON).apply {
* (GET("/api/user/") or GET("/api/users/")) { findAll() }
* POST("/api/user/", this@FooController::create)
* accept(APPLICATION_JSON).nest {
* (GET("/api/user/") or GET("/api/users/")).invoke(userHandler::findAll)
* POST("/api/users/", userHandler::create)
* }
* }
*
* fun findAllView() = ...
* fun findViewById(req: ServerRequest) = ...
* fun findAll() = ...
* fun create(req: ServerRequest) =
* }
* ```
*