Dan K
2019-07-19 f9e42817fafbb28b602b0a5873dbd90459a8a81f
commit | author | age
6e5795 1 package com.redhat.training.openshift.hello;
DK 2
3 import javax.inject.Inject;
4 import javax.ws.rs.GET;
5 import javax.ws.rs.Path;
6 import javax.ws.rs.Produces;
7
8 @Path("/")
9 public class HelloResource {
10
11     @GET
12     @Path("/hello")
13     @Produces("text/plain")
14     public String hello() {
15         String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown");
16           String message = System.getenv().getOrDefault("APP_MSG", null);
17           String response = "";
18
eaf20b 19           if (message == null) {
6e5795 20             response = "Hello world from host "+hostname+"\n";
eaf20b 21           } else {
f9e428 22             response = "Hello world from host ["+hostname+"].\n";
6e5795 23             response += "Message received = "+message+"\n";
eaf20b 24         }
6e5795 25         return response;
DK 26     }
27 }