diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java index e103edcc19..3a14094440 100644 --- a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomerController.java @@ -34,7 +34,12 @@ public class CustomerController { @RequestMapping(value = "/customer/{customerId}/orders", method = RequestMethod.GET) public List getOrdersForCustomer(@PathVariable final String customerId) { - return orderService.getAllOrdersForCustomer(customerId); + final List orders = orderService.getAllOrdersForCustomer(customerId); + for (final Order order : orders) { + final Link selfLink = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(CustomerController.class).getOrderById(customerId, order.getOrderId())).withSelfRel(); + order.add(selfLink); + } + return orders; } @RequestMapping(value = "/customers", method = RequestMethod.GET)