Is there a dynamic way to display Restful service urls?

Currently I am displaying the endpoint to my services by doing something like the following

<!DOCTYPE HTML>
<html>
<head>
    <title>RESTful Services</title>
</head>
<body>
<p>Get your greeting <a href="localhost:8080/rest/Greeting">here</a></p>
</body>
</html>

This is coming from a spring boot rest service like the following:

@RequestMapping(method = GET, path = "/Greeting" )
    public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
        return new Greeting(counter.incrementAndGet(),
                String.format(template, name));
    }

However once I deploy to a server that url will no longer be valid. Is there a way to display the url of the service regardless of environment?

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image