Browse Source

Fix code samples for nested router functions

Closes gh-28603
pull/28720/head
Arjen Poutsma 2 years ago
parent
commit
27738cc20f
  1. 18
      src/docs/asciidoc/web/webflux-functional.adoc
  2. 16
      src/docs/asciidoc/web/webmvc-functional.adoc

18
src/docs/asciidoc/web/webflux-functional.adoc

@ -590,10 +590,10 @@ RouterFunction<ServerResponse> route = route() @@ -590,10 +590,10 @@ RouterFunction<ServerResponse> route = route()
.path("/person", builder -> builder // <1>
.GET("/{id}", accept(APPLICATION_JSON), handler::getPerson)
.GET(accept(APPLICATION_JSON), handler::listPeople)
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.build();
----
<1> Note that second parameter of `path` is a consumer that takes the a router builder.
<1> Note that second parameter of `path` is a consumer that takes the router builder.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
@ -602,7 +602,7 @@ RouterFunction<ServerResponse> route = route() @@ -602,7 +602,7 @@ RouterFunction<ServerResponse> route = route()
"/person".nest {
GET("/{id}", accept(APPLICATION_JSON), handler::getPerson)
GET(accept(APPLICATION_JSON), handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
}
}
----
@ -620,7 +620,7 @@ We can further improve by using the `nest` method together with `accept`: @@ -620,7 +620,7 @@ We can further improve by using the `nest` method together with `accept`:
.nest(accept(APPLICATION_JSON), b2 -> b2
.GET("/{id}", handler::getPerson)
.GET(handler::listPeople))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.build();
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@ -631,7 +631,7 @@ We can further improve by using the `nest` method together with `accept`: @@ -631,7 +631,7 @@ We can further improve by using the `nest` method together with `accept`:
accept(APPLICATION_JSON).nest {
GET("/{id}", handler::getPerson)
GET(handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
}
}
}
@ -766,7 +766,7 @@ For instance, consider the following example: @@ -766,7 +766,7 @@ For instance, consider the following example:
.before(request -> ServerRequest.from(request) // <1>
.header("X-RequestHeader", "Value")
.build()))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.after((request, response) -> logResponse(response)) // <2>
.build();
----
@ -784,7 +784,7 @@ For instance, consider the following example: @@ -784,7 +784,7 @@ For instance, consider the following example:
ServerRequest.from(it)
.header("X-RequestHeader", "Value").build()
}
POST("/person", handler::createPerson)
POST(handler::createPerson)
after { _, response -> // <2>
logResponse(response)
}
@ -815,7 +815,7 @@ The following example shows how to do so: @@ -815,7 +815,7 @@ The following example shows how to do so:
.nest(accept(APPLICATION_JSON), b2 -> b2
.GET("/{id}", handler::getPerson)
.GET(handler::listPeople))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.filter((request, next) -> {
if (securityManager.allowAccessTo(request.path())) {
return next.handle(request);
@ -835,7 +835,7 @@ The following example shows how to do so: @@ -835,7 +835,7 @@ The following example shows how to do so:
("/person" and accept(APPLICATION_JSON)).nest {
GET("/{id}", handler::getPerson)
GET("", handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
filter { request, next ->
if (securityManager.allowAccessTo(request.path())) {
next(request)

16
src/docs/asciidoc/web/webmvc-functional.adoc

@ -612,7 +612,7 @@ RouterFunction<ServerResponse> route = route() @@ -612,7 +612,7 @@ RouterFunction<ServerResponse> route = route()
.path("/person", builder -> builder // <1>
.GET("/{id}", accept(APPLICATION_JSON), handler::getPerson)
.GET(accept(APPLICATION_JSON), handler::listPeople)
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.build();
----
<1> Note that second parameter of `path` is a consumer that takes the router builder.
@ -626,7 +626,7 @@ RouterFunction<ServerResponse> route = route() @@ -626,7 +626,7 @@ RouterFunction<ServerResponse> route = route()
"/person".nest {
GET("/{id}", accept(APPLICATION_JSON), handler::getPerson)
GET(accept(APPLICATION_JSON), handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
}
}
----
@ -644,7 +644,7 @@ We can further improve by using the `nest` method together with `accept`: @@ -644,7 +644,7 @@ We can further improve by using the `nest` method together with `accept`:
.nest(accept(APPLICATION_JSON), b2 -> b2
.GET("/{id}", handler::getPerson)
.GET(handler::listPeople))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.build();
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@ -657,7 +657,7 @@ We can further improve by using the `nest` method together with `accept`: @@ -657,7 +657,7 @@ We can further improve by using the `nest` method together with `accept`:
accept(APPLICATION_JSON).nest {
GET("/{id}", handler::getPerson)
GET("", handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
}
}
}
@ -779,7 +779,7 @@ For instance, consider the following example: @@ -779,7 +779,7 @@ For instance, consider the following example:
.before(request -> ServerRequest.from(request) // <1>
.header("X-RequestHeader", "Value")
.build()))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.after((request, response) -> logResponse(response)) // <2>
.build();
----
@ -800,7 +800,7 @@ For instance, consider the following example: @@ -800,7 +800,7 @@ For instance, consider the following example:
.header("X-RequestHeader", "Value").build()
}
}
POST("/person", handler::createPerson)
POST(handler::createPerson)
after { _, response -> // <2>
logResponse(response)
}
@ -830,7 +830,7 @@ The following example shows how to do so: @@ -830,7 +830,7 @@ The following example shows how to do so:
.nest(accept(APPLICATION_JSON), b2 -> b2
.GET("/{id}", handler::getPerson)
.GET(handler::listPeople))
.POST("/person", handler::createPerson))
.POST(handler::createPerson))
.filter((request, next) -> {
if (securityManager.allowAccessTo(request.path())) {
return next.handle(request);
@ -852,7 +852,7 @@ The following example shows how to do so: @@ -852,7 +852,7 @@ The following example shows how to do so:
("/person" and accept(APPLICATION_JSON)).nest {
GET("/{id}", handler::getPerson)
GET("", handler::listPeople)
POST("/person", handler::createPerson)
POST(handler::createPerson)
filter { request, next ->
if (securityManager.allowAccessTo(request.path())) {
next(request)

Loading…
Cancel
Save