0

I have a POST method at

http://example.com/rest/cars

returning JSON representation of the newly created object.

How can I build the full path for interacting with the created resource? Example locations could be

http://example.com/rest/cars/1

or

http://anotherdomain.com/rest/cars/1

I want to fetch the domain part dynamically inside the application. I have tried org.springframework.web.context.WebApplicationContext and several other places, but to no success. Has anyone done this?

I use Spring framework and deploy in Tomcat if that changes anything...

Edit:

Following comment asking about what I try to achieve:

String domainPart = "http://howdoigethis.com"; // need to fetch domain dynamically
Integer id = 1;
String selfLocationOfId1 = domainPart + "/rest/cars/" + id;
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

0 Answers0