title: Cross-service linking for HATEOAS micro-services
body: <p>I have a number of micro-services built with Spring Boot, so for a bit of fun, I thought I'd have a go at adding HATEOAS to them to help set up cross-resource linking. It seems to work quite nicely within a particular project, but I was wondering whether there's a good way to link across APIs. As an example, imagine I have 3 services:</p>
  
  <p>A user details service:
  Code:</p>
  
  <pre><code>/users/{userid}
  </code></pre>
  
  <p>A user calendar service:
  Code:</p>
  
  <pre><code>/users/{userid}/appointments
  /users/{userid}/appointments/{appointmentid}
  </code></pre>
  
  <p>A user messaging service:
  Code:</p>
  
  <pre><code>/users/{userid}/messages
  /users/{userid}/messages/{messageid}
  </code></pre>
  
  <p>To make this browsable via the API, it would be good to have links from a user resource to its appointments and messages. Similarly, it would be nice to have links back from those resources. This is all very achievable when I have a single API with everything on the classpath, where I can write code such as:</p>
  
  <p>Code:</p>
  
  <pre><code>user.add(linkTo(methodOn(CalendarController.class).appointments(user.getKey())).withRel("appointments"))
  </code></pre>
  
  <p>However I'm not able to do this if CalendarController is not on the classpath of the service I'm currently hitting.</p>
  
  <p>Is there a good/recommended method for creating links to controllers which are not in the current project?</p>
  
  <p>Referenced from <a href="http://forum.spring.io/forum/spring-projects/web/749306-cross-service-linking-for-hateoas-micro-services">spring forums</a></p>