title: How to retrieve the API Gateway URI upon post
body: <p>I'm developing a system in a microservices architecture using java8 and Spring Cloud. I implemented a post rest controller that receives an object in json and then saves it in the database. The problem is; how do I get the URI containing the API Gateway of the just saved object so I can return it on the created responde body?</p>
  
  <p>Like, when I use <code>
  URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(savedProfile.getId()).toUri();
  </code> I get <code>http://Boss.mshome.net:8081/profile/1</code> instead of <code>localhost:8765/nukr-profile-service/profile/1</code> which is the endpoint with the API Gateway's path.</p>
  
  <p>What's the best practice to retrieve this URI?</p>