From 18d8876dc8330ac816473aad1139b94be53c1794 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Mon, 10 Apr 2017 10:25:14 +0200 Subject: [PATCH] Update RouterFunctionExtensions documentation --- .../server/RouterFunctionExtensions.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt index f53ba7fc13..2f11648ad6 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt @@ -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 { + * @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) = * } * ``` *