Skip to content

Instantly share code, notes, and snippets.

@rinormaloku
Last active February 8, 2018 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rinormaloku/bf946a4a52d5172312f17450234d4192 to your computer and use it in GitHub Desktop.
Save rinormaloku/bf946a4a52d5172312f17450234d4192 to your computer and use it in GitHub Desktop.
[Sentiment Controller in Spring WebApp] Sentiment controller that takes requests from React #spring #controller
@CrossOrigin(origins = "*")
@RestController
public class SentimentController {
@Value("${sa.logic.api.url}") // #1
private String saLogicApiUrl;
@PostMapping("/sentiment")
public SentimentDto sentimentAnalysis(@RequestBody SentenceDto sentenceDto) {
RestTemplate restTemplate = new RestTemplate();
return restTemplate.postForEntity(saLogicApiUrl + "/analyse/sentiment", // #2
sentenceDto, SentimentDto.class)
.getBody();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment