Reputation: 75
I'm implementing a REST-API using the Spring Boot framework. Now this REST-API has to call another REST-API and just needs to pass through the incoming HTTP-Response as is, basically functioning as a gateway.
Is there a simple way to achieve this without mapping the response to a bean?
Upvotes: 0
Views: 448
Reputation: 752
I would use RestTemplate. Its only a few lines of code.
https://spring.io/guides/gs/consuming-rest/
This would map in into a String if that if fine for you:
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl = "http://localhost:8080/spring-rest/foos";
ResponseEntity<String> respons = restTemplate.getForEntity(fooResourceUrl + "/1", String.class);
Upvotes: 1