diff --git a/rest-microservices-customers/pom.xml b/rest-microservices-customers/pom.xml index 94fbc00..c776ee2 100644 --- a/rest-microservices-customers/pom.xml +++ b/rest-microservices-customers/pom.xml @@ -26,6 +26,7 @@ spring-hateoas + com.jayway.jsonpath json-path diff --git a/rest-microservices-customers/src/main/java/example/customers/integration/CustomerResourceProcessor.java b/rest-microservices-customers/src/main/java/example/customers/integration/CustomerResourceProcessor.java index ac2186e..477d21a 100644 --- a/rest-microservices-customers/src/main/java/example/customers/integration/CustomerResourceProcessor.java +++ b/rest-microservices-customers/src/main/java/example/customers/integration/CustomerResourceProcessor.java @@ -40,8 +40,8 @@ public class CustomerResourceProcessor implements ResourceProcessor> { private static final String X_FORWARDED_HOST = "X-Forwarded-Host"; - private final StoreIntegration storeIntegration; - private final Provider request; + private final StoreIntegration storeIntegration; + private final Provider request; @Override public Resource process(Resource resource) { @@ -49,14 +49,14 @@ public Resource process(Resource resource) { Customer customer = resource.getContent(); Location location = customer.getAddress().getLocation(); - Map parameters = new HashMap<>(); - parameters.put("location", String.format("%s,%s", location.getLatitude(), location.getLongitude())); - parameters.put("distance", "50"); - String host = request.get().getHeader(X_FORWARDED_HOST); - Link link = storeIntegration.getStoresByLocationLink(parameters, host); - if (link != null) { - resource.add(link.withRel("stores-nearby")); - } + Map parameters = new HashMap<>(); + parameters.put("location", String.format("%s,%s", location.getLatitude(), location.getLongitude())); + parameters.put("distance", "50km"); + String host = this.request.get().getHeader(X_FORWARDED_HOST); + Link link = this.storeIntegration.getStoresByLocationLink(parameters, host); + if (link != null) { + resource.add(link.withRel("stores-nearby")); + } return resource; }