I am retrieving a publisher Mono<ProductOrder>
from mongo db
I have another publisher Mono<CommandResponse>
I want to set ProductOrder
object into CommandResponse
as it is a part of that class. like commandResponse.setProductOrder(po instance)
CommandResponse
will also have different Mono
or String or Int
apart from ProductOrder
instance
Finally want to return Mono<ServerResponse>
which would contain body of CommandResponse
i am not being able to set the Mono<ProductOrder>
object into Mono<CommandResponse>
Pleas help. Thanks.
CODE SNIPPET
@Component
public class Handler {
@Autowired
private MongoService service;
public Mono<ServerResponse> get(ServerRequest request) {
Mono<ProductOrder> p = service.queryById();
> Here, in the return statement i want to return Mono<CommandResponse>
> instead of Mono<ProductOrder> in the response body
> remember: CommandResponse has a reference to ProductOrder
return
ServerResponse.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(p, ProductOrder.class).map(null);
);
}
}