Transform return GET in Response Imperative

This commit is contained in:
Valentin CZERYBA 2022-06-11 00:24:32 +02:00
parent 4dedad4528
commit b2389b5ef8

View File

@ -1,35 +1,32 @@
package com.covas.Resources;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Flow;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import io.quarkus.mailer.Mail;
import io.quarkus.mailer.MailTemplate;
import io.quarkus.mailer.reactive.ReactiveMailer;
import io.quarkus.mailer.MailTemplate;
import io.quarkus.qute.CheckedTemplate;
import io.smallrye.mutiny.Uni;
@Path("mail")
public class MailRessource {
@Inject
private ReactiveMailer mail;
@Inject
private MailTemplate hello;
@GET
@Path("async")
public CompletionStage<Response> sendMail(){
//return mail.send(Mail.withText("valcze80@gmail.com", "async", "toto"))
//.subscribeAsCompletionStage()
//.thenApply(x -> Response.accepted().build());
return hello.to("valcze80@gmail.com").subject("test").data("name", "Robert").send().subscribeAsCompletionStage().thenApply(x -> Response.accepted().build());
public Response sendMail(){
hello.to("valcze808@gmail.com").subject("test").data("name", "Robert").send().subscribeAsCompletionStage();
return Response.ok().build();
}