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