微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决带有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 举报,一经查实,本站将立刻删除。