Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Feb 18, 2019
1 parent 19f792d commit caa1730
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/docs/asciidoc/languages/kotlin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,17 @@ fun routes(userHandler: UserHandler): RouterFunction<ServerResponse> = coRouter
GET("/api/user", userHandler::listApi)
}
class UserHandler(private val client: WebClient) {
class UserHandler(builder: WebClient.Builder) {
suspend fun listApi(request: ServerRequest): ServerResponse =
ServerResponse.ok().contentType(MediaType.APPLICATION_JSON_UTF8).bodyAndAwait(
client.get().uri("...").awaitResponse().awaitBody<User>())
private val client = builder.baseUrl("...").build()
suspend fun listView(request: ServerRequest): ServerResponse =
ServerResponse.ok().renderAndAwait("users", mapOf("users" to
client.get().uri("...").awaitResponse().awaitBody<User>()))
suspend fun listApi(request: ServerRequest): ServerResponse =
ServerResponse.ok().contentType(MediaType.APPLICATION_JSON_UTF8).bodyAndAwait(
client.get().uri("...").awaitResponse().awaitBody<User>())
}
----

Expand Down

0 comments on commit caa1730

Please sign in to comment.