小编Mus*_*taq的帖子

使用 io.smallrye.mutiny.Uni 创建响应对象

我正在尝试学习在 Quarkus 框架上使用 ReactiveMongoClient。

我以 Uni> 的身份发送回复部分成功

@GET
@Path("/unpaginated")
public Uni<List<Staff>> unpaginatedStaffList() {
    return staffService.getStaffResponse();
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试获取其他类(​​StaffResponse)的对象以包含用于分页的 Link 对象时,我没有获得任何 Staff 记录。(现在我已经硬编码了分页链接)

@GET
@Path("/paginated")
public StaffResponse paginatedStaffList() {
    List<Link> links = LinkService.getLinks("/staff?page=2&limit=20", "next");
    Uni<List<Staff>> staff = (Uni<List<Staff>>) staffService.getStaffResponse();
    return new StaffResponse(links, staff);
}
Run Code Online (Sandbox Code Playgroud)

响应中的“工作人员”为空。

MongoClient 正在返回员工列表,看起来 Response 对象没有获取列表。尝试阅读 SmallRye Mutiny 文档 - 无法解决。

请帮忙。

我已将代码提交到:https://github.com/doepradhan/staffApi 和示例 json 数据文件(https://github.com/doepradhan/staffApi/blob/master/sample-staff-data.json

非常感谢您的热心帮助。

rest quarkus smallrye-reactive-messaging

3
推荐指数
1
解决办法
7259
查看次数