forked from JavaWebinar/masterjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc87c0f
commit 1299545
Showing
5 changed files
with
129 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
services/mail-service/src/main/java/ru/javaops/masterjava/service/mail/rest/MailRS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ru.javaops.masterjava.service.mail.rest; | ||
|
||
|
||
import org.hibernate.validator.constraints.NotBlank; | ||
import ru.javaops.masterjava.service.mail.GroupResult; | ||
import ru.javaops.masterjava.service.mail.MailServiceExecutor; | ||
import ru.javaops.masterjava.service.mail.MailWSClient; | ||
import ru.javaops.masterjava.web.WebStateException; | ||
|
||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.MediaType; | ||
import java.util.Collections; | ||
|
||
@Path("/") | ||
public class MailRS { | ||
@GET | ||
@Path("test") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String test() { | ||
return "Test"; | ||
} | ||
|
||
@POST | ||
@Path("send") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public GroupResult send(@NotBlank @FormParam("users") String users, | ||
@FormParam("subject") String subject, | ||
@NotBlank @FormParam("body") String body) throws WebStateException { | ||
|
||
return MailServiceExecutor.sendBulk(MailWSClient.split(users), subject, body, Collections.emptyList()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...es/mail-service/src/main/java/ru/javaops/masterjava/service/mail/rest/MailRestConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.javaops.masterjava.service.mail.rest; | ||
|
||
import org.glassfish.jersey.server.ResourceConfig; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
|
||
@ApplicationPath("rest") | ||
public class MailRestConfig extends ResourceConfig { | ||
public MailRestConfig() { | ||
packages("ru.javaops.masterjava.service.mail.rest"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters