From b2389b5ef865574589ae189789747313afffba16 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 11 Jun 2022 00:24:32 +0200 Subject: [PATCH] Transform return GET in Response Imperative --- .../com/covas/Resources/MailRessource.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/covas/Resources/MailRessource.java b/src/main/java/com/covas/Resources/MailRessource.java index cc979dc..d97a839 100644 --- a/src/main/java/com/covas/Resources/MailRessource.java +++ b/src/main/java/com/covas/Resources/MailRessource.java @@ -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 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(); }