Dan K
2019-07-19 c37d409c1d8ca28f3fbe38ee32415a226b5a8db4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.redhat.training.example.javaserverhost.rest;
 
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import java.net.InetAddress;
 
@Path("/")
public class ServerHostEndPoint {
 
  @GET
  @Produces("text/plain")
  public Response doGet() {
    String host = "";
    try {
      host = InetAddress.getLocalHost().getHostName();
    }
    catch (Exception e) {
       e.printStackTrace();
    }
    String msg = "I am running on server "+host+" Version 1.0 \n";
    return Response.ok(msg).build();
  }
}