我有端点,它可以返回同步和异步结果
@POST
@Path("/create-account")
public CompletionStage<Response> createAccount(...) {
if (preconditions) {
return myAsyncFunction(...);
}
else {
// how to return error immediately???
return Response.status(Response.Status.BAD_REQUEST).build(); // incorrect return type
}
}
如何故意返回一些东西,即同步?