Fix code samples for nested router functions

Closes gh-28603
This commit is contained in:
Arjen Poutsma
2022-06-10 13:36:33 +02:00
parent babff8e635
commit 27738cc20f
2 changed files with 17 additions and 17 deletions

View File

@@ -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()
"/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`:
.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`:
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:
.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:
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:
.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:
("/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)

View File

@@ -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()
"/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`:
.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`:
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:
.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:
.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:
.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:
("/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)