Micronaut 2.1.0中使用RXjava 3的反应式Get方法
我尝试使用反应式非阻塞方法来创建RESTAPIMicronaut 2.1.0中使用RXjava 3的反应式Get方法,java,rx-java,micronaut,rx-java3,micronaut-rest,Java,Rx Java,Micronaut,Rx Java3,Micronaut Rest,我尝试使用反应式非阻塞方法来创建RESTAPI public HttpResponse<Single<ProductViewModel>> findById(String id) { LOG.info(String.format("Finding the product with id : %s", id)); iProductManager.findById(id).subscribe(item -> {
public HttpResponse<Single<ProductViewModel>> findById(String id) {
LOG.info(String.format("Finding the product with id : %s", id));
iProductManager.findById(id).subscribe(item -> {
if (item == null)
return HttpResponse.notFound();
return HttpResponse.ok().eTag(item.getId())
.location(new URI(String.format("/%s", item.getId())))
.body(item);
}, error -> {
LOG.error(error.getMessage());
return HttpResponse.status(HttpStatus.INTERNAL_SERVER_ERROR, "URI Syntax Exception");
});
}
在error方法中,我想在返回值时创建eTag和location头。我怎样才能做到这一点
#错误
有人能用RxJava3以反应式的方式向我展示上面的代码吗
return HttpResponse.ok().eTag(item.getId())
.location(new URI(String.format("/%s", item.getId())))
.body(item);
Incompatible types: expected void but the lambda body is neither a statement expression nor a void-compatible block