I'm investigating spring-cloud and I've set up two microservices "offers" and "customers" as eureka clients.
The customers app has:
@Data
public class Customer extends ResourceSupport {
private Long customerId;
private String name;
}
@RestController
@RequestMapping("/customers")
@ExposesResourceFor(Customer.class)
public class CustomersController {
...
}
and the offers app has:
@Data
public class Offer extends ResourceSupport {
private final Long offerId;
private final Long priceI;
private final Customer customer;
}
@RestController
@RequestMapping("/offers")
@ExposesResourceFor(Offer.class)
public class OfferController {
...
}
How would I organize the code so that you can add a Customer
link to the Offer
instances? Autowiring an EntityLink
would of course not work since the two controllers live in separate apps.
Would it be reasonable to create interfaces for all the controllers with the @RequestMapping
on them and shared the inerfaces in all apps so that you could use e.g. Link link = linkTo(methodOn(OfferController.class).getOffer(2L)).withSelfRel();
?