我需要编写一个方法
Location
从端点获取标头- 生成一系列
Some
,每个都应该从Location
从第一个端点获取的内容中检索。 - 需要返回一个
Flux<Some>
看起来像这样。
private WebClient client;
Flux<Some> getSome() {
// Get the Location header from an endpoint
client
.post()
.exchange()
.map(r -> r.headers().header("Location"))
// Now I need to keep invoking the Location endpoint for Some.class
// And Some.class has an attribute for pending/completion status.
// e.g.
while (true)
final Some some = client
.get()
.url(...) // the Location header value above
.retrieve()
.bodyToMono(Some.class)
.block()
;
}
}
如何使用完成属性将其映射Mono<String>
到一段时间?Flux<Some>
Some#status
// should return Flux<Some>
client
.post()
.exchange()
.map(r -> r.headers().header("Location"))
.flatMapMany(location -> {
// invokes location while retrieved Some#status is not `completed`
// @@?
})
;