Created
March 14, 2018 20:06
-
-
Save radutoev/92364d32d5e8209e79bdd89799410241 to your computer and use it in GitHub Desktop.
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
@Autowired | |
TokenString tokenString; | |
public CompletableFuture<String> callBAsync() { | |
return supplyAsync(() -> { | |
logger.info("calling B"); | |
RestTemplate restTemplate = new RestTemplate(); | |
HttpHeaders headers = new HttpHeaders(); | |
headers.set("Authorization", "bearer "+tokenString.getValue()); | |
HttpEntity entity = new HttpEntity(headers); | |
ResponseEntity re = restTemplate.exchange( | |
<SERVICE_B_ADDRESS>, | |
HttpMethod.GET, | |
entity, | |
String.class); | |
return re.getStatusCode().equals(HttpStatus.OK) ? | |
"ok" : "not ok"; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment