public Mono<ServerResponse> getMessage(ServerRequest request) {
//this call returns Mono<ApiClientResponse>
return apiClient.hystrixWrappedGetMessages(request.headers().asHttpHeaders(), request.queryParams())
.switchIfEmpty(/* Here */)
}
Run Code Online (Sandbox Code Playgroud)
请原谅代码稍微不完整,当我遇到这个问题时,我正在重组它。要点是 /* Here */ 在调用中switchIfEmpty(),编译器强制使用类型Mono<ApiClientResponse>,但是当hystrixWrappedGetMessages()返回时Mono.empty()我想通过返回 204 来处理它Mono<ServerResponse>,否则我想返回 200。我怎样才能做到这一点?
理想情况下,我可以在地图调用中检查它是否是 Mono.empty() ,但如果它是空的 Mono,它似乎不会输入地图。考虑过使用可选选项,但它们似乎与 Monos 不能很好地配合。
java reactive-programming reactor-netty spring-webflux spring-webclient
这只是swift中指针的一个练习,但是我试图编写一个函数来打印指向self的指针,但我不断收到错误"无法分配给C类的不可变值".这是Swift中甚至可能实现的吗?
class C {
static var c = C()
var a = 1
func printMyPointer() {
printPointer(&self) //cannot assign to immutable value of type C
}
func printPointer(ptr:UnsafePointer<C>) {
print(ptr)
}
}
C.c.printMyPointer()
Run Code Online (Sandbox Code Playgroud)