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