Skip to content

Instantly share code, notes, and snippets.

@radutoev
Created March 14, 2018 20:06
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 radutoev/92364d32d5e8209e79bdd89799410241 to your computer and use it in GitHub Desktop.
Save radutoev/92364d32d5e8209e79bdd89799410241 to your computer and use it in GitHub Desktop.
@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