commit | author | age
|
497620
|
1 |
package com.redhat.training.openshift.hello; |
RA |
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 |
if (message == null) |
|
19 |
response = "Hello world from host "+hostname+"\n"; |
|
20 |
else |
|
21 |
response = "Hello world from host ["+hostname+"]. Message received = "+message+"\n"; |
|
22 |
return response; |
|
23 |
} |
|
24 |
} |