Dan K
2019-07-19 1dc1e7e1dd3fcfdf784c0bb62c330bc32c54b84d
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
26
27
package com.redhat.training.openshift.hello;
 
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
 
@Path("/")
public class HelloResource {
 
    @GET
    @Path("/hello")
    @Produces("text/plain")
    public String hello() {
        String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown");
          String message = System.getenv().getOrDefault("APP_MSG", null);
          String response = "";
 
          if (message == null) {
            response = "Hello world from host "+hostname+"\n";
          } else {
            response = "Hello world from host ["+hostname+"].";
            response += "Message received = "+message+"\n";
        }
        return response;
    }
}