Skip to content

Commit

Permalink
logging header for troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Jul 15, 2024
1 parent 2ec4a03 commit 37290ec
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public Collection<Pet> getPets(String category) {
try {
Consumer<HttpHeaders> consumer = it -> it.addAll(this.webRequest.getHeaders());

// log all of the headers in the petServiceWebClient request
logger.info("Headers in the petServiceWebClient request " + this.containerEnvironment.getPetStorePetServiceURL());
this.webRequest.getHeaders().forEach((k, v) -> {
logger.info("Key: " + k + " Value: " + v);
});
logger.info("Key: " + "Ocp-Apim-Subscription-Key" + " Value: " + this.containerEnvironment.getPetStoreServicesSubscriptionKey());

pets = this.petServiceWebClient.get().uri("petstorepetservice/v2/pet/findByStatus?status=available")
.accept(MediaType.APPLICATION_JSON)
.headers(consumer)
Expand Down Expand Up @@ -107,6 +114,8 @@ public Collection<Pet> getPets(String category) {
pet.setCategory(new Category());
pet.setId((long) 0);
pets.add(pet);
logger.error(wce.getMessage());

} catch (IllegalArgumentException iae) {
// little hack to visually show the error message within our Azure Pet Store
// Reference Guide (Academic Tutorial)
Expand All @@ -117,7 +126,9 @@ public Collection<Pet> getPets(String category) {
pet.setCategory(new Category());
pet.setId((long) 0);
pets.add(pet);
logger.error(iae.getMessage());
}

return pets;
}

Expand Down

0 comments on commit 37290ec

Please sign in to comment.