@@ -18,7 +18,6 @@ package io.spring.github.api
1818
1919import org.springframework.http.HttpHeaders
2020import org.springframework.http.HttpStatus
21- import org.springframework.stereotype.Component
2221import org.springframework.web.reactive.function.client.ClientResponse
2322import org.springframework.web.reactive.function.client.WebClient
2423import org.springframework.web.reactive.function.client.bodyToFlux
@@ -28,7 +27,6 @@ import reactor.core.publisher.Flux
2827import reactor.core.publisher.Mono
2928import java.io.ByteArrayInputStream
3029import java.io.InputStream
31- import java.lang.IllegalStateException
3230import java.lang.RuntimeException
3331import java.net.URI
3432import java.util.*
@@ -65,8 +63,7 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
6563 return webClient.get()
6664 .uri(" $baseGitHubUrl /teams/$teamId /memberships/$username " )
6765 .headers { h -> h.setBearerAuth(accessToken) }
68- .exchange()
69- .flatMap { response ->
66+ .exchangeToMono { response ->
7067 val status = response.statusCode()
7168 if (status == HttpStatus .OK ) {
7269 Mono .just(true )
@@ -94,9 +91,8 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
9491 .toUri()
9592 return webClient.patch()
9693 .uri(uri)
97- .syncBody(body)
98- .exchange()
99- .flatMap { clientResponse ->
94+ .bodyValue(body)
95+ .exchangeToMono { clientResponse ->
10096 val status = clientResponse.statusCode()
10197 if (status.is2xxSuccessful)
10298 clientResponse.bodyToMono<String >()
@@ -117,9 +113,8 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
117113 .toUri()
118114 return webClient.post()
119115 .uri(uri)
120- .syncBody(mapOf (Pair (" body" , comment)))
121- .exchange()
122- .flatMap { clientResponse ->
116+ .bodyValue(mapOf (Pair (" body" , comment)))
117+ .exchangeToMono { clientResponse ->
123118 val status = clientResponse.statusCode()
124119 if (status.is2xxSuccessful)
125120 clientResponse.bodyToMono<String >()
@@ -172,8 +167,7 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
172167 .toUri()
173168 return webClient.get()
174169 .uri(uri)
175- .exchange()
176- .flatMap { clientResponse ->
170+ .exchangeToMono { clientResponse ->
177171 val status = clientResponse.statusCode()
178172 if (status.is2xxSuccessful)
179173 clientResponse.bodyToMono<GithubContents >()
@@ -192,9 +186,8 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
192186 .toUri()
193187 return webClient.post()
194188 .uri(uri)
195- .syncBody(issue)
196- .exchange()
197- .flatMap { clientResponse ->
189+ .bodyValue(issue)
190+ .exchangeToMono { clientResponse ->
198191 val status = clientResponse.statusCode()
199192 if (status.is2xxSuccessful)
200193 clientResponse.bodyToMono<CreateIssueResponse >().map { r -> r.number }
@@ -211,8 +204,7 @@ class WebClientGitHubApi(val webClient: WebClient = WebClient.create(), val base
211204 .toUri()
212205 return webClient.get()
213206 .uri(uri)
214- .exchange()
215- .flatMap { clientResponse ->
207+ .exchangeToMono { clientResponse ->
216208 val status = clientResponse.statusCode()
217209 if (status.is2xxSuccessful)
218210 clientResponse.bodyToMono<Issue >()
0 commit comments