aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index 3d6bc8cf0..3186b796e 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Inject;
import java.io.IOException;
@@ -82,6 +83,8 @@ public class NewMessage {
private String imgDir;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String tmpDir;
+ @Value("${api_url:http://localhost:8081}")
+ private String apiUrl;
private RestTemplate rest = new RestTemplate();
private static final Logger logger = LoggerFactory.getLogger(NewMessage.class);
@@ -165,8 +168,9 @@ public class NewMessage {
if (StringUtils.isNotEmpty(attachmentFName.toString())) {
params.add("img", attachmentFName.toASCIIString());
}
+ URI postUri = UriComponentsBuilder.fromUriString(apiUrl).path("/post").build().toUri();
ResponseEntity<CommandResult> result = rest.postForEntity(
- "http://localhost:8081/post",
+ postUri,
request, CommandResult.class);
logger.info("/comment: {}", jsonMapper.writeValueAsString(result.getBody()));
return "redirect:/" + msg.getUser().getName() + "/" + mid + "#" + result.getBody().getNewMessage().get().getRid();
@@ -203,8 +207,9 @@ public class NewMessage {
params.add("body", String.format("@%s %s", userTo.getName(), body));
params.add("hash", userService.getHashByUID(visitor.getUid()));
+ URI postUri = UriComponentsBuilder.fromUriString(apiUrl).path("/post").build().toUri();
ResponseEntity<CommandResult> result = rest.postForEntity(
- "http://localhost:8081/post",
+ postUri,
request, CommandResult.class);
logger.info("/pm: {}", jsonMapper.writeValueAsString(result.getBody()));
return "redirect:/pm/sent";
@@ -243,9 +248,9 @@ public class NewMessage {
if (StringUtils.isNotEmpty(attachmentFName.toString())) {
params.add("img", attachmentFName.toASCIIString());
}
+ URI postUri = UriComponentsBuilder.fromUriString(apiUrl).path("/post").build().toUri();
try {
- ResponseEntity<CommandResult> result = rest.postForEntity(
- "http://localhost:8081/post",
+ ResponseEntity<CommandResult> result = rest.postForEntity(postUri,
request, CommandResult.class);
if (result.getBody().getNewMessage().isPresent()) {
logger.info("/post: {}", jsonMapper.writeValueAsString(result.getBody()));