Skip to content

Commit 18d8876

Browse files
committed
Update RouterFunctionExtensions documentation
1 parent 57f1f4c commit 18d8876

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,25 @@ import org.springframework.http.MediaType
2222
import reactor.core.publisher.Mono
2323

2424
/**
25-
* Provide a routing DSL for [RouterFunctions] and [RouterFunction] in order to be able to
26-
* write idiomatic Kotlin code as below:
25+
* Provide a [RouterFunction] Kotlin DSL in order to be able to write idiomatic Kotlin code as below:
2726
*
2827
* ```kotlin
2928
*
30-
* @Controller
31-
* class FooController : RouterFunction<ServerResponse> {
29+
* @Configuration
30+
* class ApplicationRoutes(val userHandler: UserHandler) {
3231
*
33-
* override fun route(req: ServerRequest) = route(req) {
34-
* accept(TEXT_HTML).apply {
35-
* (GET("/user/") or GET("/users/")) { findAllView() }
36-
* GET("/user/{login}", this@FooController::findViewById)
32+
* @Bean
33+
* fun mainRouter() = router {
34+
* accept(TEXT_HTML).nest {
35+
* (GET("/user/") or GET("/users/")).invoke(userHandler::findAllView)
36+
* GET("/users/{login}", userHandler::findViewById)
3737
* }
38-
* accept(APPLICATION_JSON).apply {
39-
* (GET("/api/user/") or GET("/api/users/")) { findAll() }
40-
* POST("/api/user/", this@FooController::create)
38+
* accept(APPLICATION_JSON).nest {
39+
* (GET("/api/user/") or GET("/api/users/")).invoke(userHandler::findAll)
40+
* POST("/api/users/", userHandler::create)
4141
* }
4242
* }
4343
*
44-
* fun findAllView() = ...
45-
* fun findViewById(req: ServerRequest) = ...
46-
* fun findAll() = ...
47-
* fun create(req: ServerRequest) =
4844
* }
4945
* ```
5046
*

0 commit comments

Comments
 (0)