forked from vmware-tanzu-learning/pal-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvController.java
More file actions
41 lines (33 loc) · 1.23 KB
/
EnvController.java
File metadata and controls
41 lines (33 loc) · 1.23 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package io.pivotal.pal.tracker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class EnvController {
private final String port;
private final String memoryLimit;
private final String cfInstanceIndex;
private final String cfInstanceAddress;
public EnvController(
@Value("${PORT:NOT SET}") String port,
@Value("${MEMORY_LIMIT:NOT SET}") String memoryLimit,
@Value("${CF_INSTANCE_INDEX:NOT SET}") String cfInstanceIndex,
@Value("${CF_INSTANCE_ADDR:NOT SET}") String cfInstanceAddress
) {
this.port = port;
this.memoryLimit = memoryLimit;
this.cfInstanceIndex = cfInstanceIndex;
this.cfInstanceAddress = cfInstanceAddress;
}
@GetMapping("/env")
public Map<String, String> getEnv() {
Map<String, String> env = new HashMap<>();
env.put("PORT", port);
env.put("MEMORY_LIMIT", memoryLimit);
env.put("CF_INSTANCE_INDEX", cfInstanceIndex);
env.put("CF_INSTANCE_ADDR", cfInstanceAddress);
return env;
}
}