diff options
author | Vitaly Takmazov | 2017-09-05 13:53:17 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-09-05 13:53:17 +0300 |
commit | 4ea29d56746b764d14838b64d43ca1358557b50f (patch) | |
tree | 641912e24d76104bac5255036927ba6eeb2d0340 /juick-api | |
parent | fb734b50962744f4cdfc51e7a228de18bc96130a (diff) |
api: no dependency on Servlet API anymore
Diffstat (limited to 'juick-api')
4 files changed, 12 insertions, 14 deletions
diff --git a/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java b/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java index 1a79cbec..e0bbc698 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java +++ b/juick-api/src/main/java/com/juick/api/controllers/MessengerWebhook.java @@ -27,8 +27,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; /** @@ -52,8 +52,8 @@ public class MessengerWebhook { } @RequestMapping(value = "/fbwbhk", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) - public void processUpdate(HttpServletRequest req) throws IOException { - String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8); + public void processUpdate(InputStream body) throws IOException { + String data = IOUtils.toString(body, StandardCharsets.UTF_8); logger.info("got data: {}", data); } } diff --git a/juick-api/src/main/java/com/juick/api/controllers/Post.java b/juick-api/src/main/java/com/juick/api/controllers/Post.java index 7696b7d8..5a32ade0 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/Post.java +++ b/juick-api/src/main/java/com/juick/api/controllers/Post.java @@ -43,9 +43,9 @@ import javax.inject.Inject; import javax.mail.Session; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; -import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -224,10 +224,8 @@ public class Post { @PostMapping("/mail") @ResponseStatus(value = HttpStatus.OK) - public void processMail(HttpServletRequest req) throws Exception { - String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8); - logger.info("got data: {}", data); - MimeMessage msg = new MimeMessage(session, IOUtils.toInputStream(data, StandardCharsets.UTF_8)); + public void processMail(InputStream data) throws Exception { + MimeMessage msg = new MimeMessage(session, data); String from = msg.getFrom().length > 1 ? ((InternetAddress) msg.getSender()).getAddress() : ((InternetAddress) msg.getFrom()[0]).getAddress(); logger.info("got msg from {}", from); diff --git a/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java b/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java index 8034a284..82622652 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java +++ b/juick-api/src/main/java/com/juick/api/controllers/SkypeEndpoint.java @@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; /** @@ -38,8 +38,8 @@ public class SkypeEndpoint { private static final Logger logger = LoggerFactory.getLogger(SkypeEndpoint.class); @RequestMapping(value = "/skypebotendpoint", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) - public void doPost(HttpServletRequest req) throws IOException { - String data = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8); + public void doPost(InputStream body) throws IOException { + String data = IOUtils.toString(body, StandardCharsets.UTF_8); logger.info("got data: {}", data); } } diff --git a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java index be29ee62..dc10ceba 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java +++ b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java @@ -34,8 +34,8 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; @@ -55,8 +55,8 @@ public class TelegramWebhook { @RequestMapping(value = "/tlgmbtwbhk", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) - public void processUpdate(HttpServletRequest request) throws IOException { - Update update = BotUtils.parseUpdate(IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8)); + public void processUpdate(InputStream body) throws IOException { + Update update = BotUtils.parseUpdate(IOUtils.toString(body, StandardCharsets.UTF_8)); Message message = update.message(); if (update.message() == null) { message = update.editedMessage(); |