Mono
現在のマイルストーン (M4) のドキュメントには、 usingを取得する方法の例が示されていますWebClient
。
WebClient webClient = WebClient.create(new ReactorClientHttpConnector());
ClientRequest<Void> request = ClientRequest.GET("http://example.com/accounts/{id}", 1L)
.accept(MediaType.APPLICATION_JSON).build();
Mono<Account> account = this.webClient
.exchange(request)
.then(response -> response.body(toMono(Account.class)));
text/event-stream
WebClient を使用して(を返すサービスから) ストリーミングされたデータを Flux に取得するにはどうすればよいですか? 自動ジャクソン変換をサポートしていますか?
これは以前のマイルストーンで行った方法ですが、API が変更されており、それを行う方法が見つかりません。
final ClientRequest<Void> request = ClientRequest.GET(url)
.accept(MediaType.TEXT_EVENT_STREAM).build();
Flux<Alert> response = webClient.retrieveFlux(request, Alert.class)