我正在使用 Kotlin和Arrow以及来自. 我想做的是将Mono实例转换为Either。spring-webflux
在响应成功或返回错误时Either
调用创建实例。Either.right(..)
WebClient
Either.left(..)
WebClient
我正在寻找的是一种Mono
类似于Either.fold(..)的方法,我可以在其中映射成功和错误的结果并返回与 a 不同的类型Mono
。像这样的东西(伪代码不起作用):
val either : Either<Throwable, ClientResponse> =
webClient().post().exchange()
.fold({ throwable -> Either.left(throwable) },
{ response -> Either.right(response)})
一个人应该怎么走?