带有RXjava 3的Micronaut 2.1.0中的Reactive Get方法

问题描述

我正在尝试使用反应性非阻塞方法来创建Rest API。

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");
        });
    }

下面的代码错误

return HttpResponse.ok().eTag(item.getId())
                    .location(new URI(String.format("/%s",item.getId())))
                    .body(item);

,在error方法中,我想在返回值时创建eTag和location标头。我该如何实现

#Error

Incompatible types: expected void but the lambda body is neither a statement expression nor a void-compatible block

有人可以使用rxjava 3以反应方式向我展示上面的适当代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)