forked from socialsky-io/go-actuator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenv.go
28 lines (25 loc) · 722 Bytes
/
env.go
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
package actuator
import (
"net/http"
)
func getEnvironmentVariables(config *Config) map[string]string {
variables := make(map[string]string)
/*
for _, e := range os.Environ() {
keyValue := strings.SplitN(e, equals, 2)
if len(keyValue) == 2 {
variables[keyValue[0]] = keyValue[1]
}
}
*/
variables[EnvKey] = config.Env
return variables
}
// getEnvHandler is used to provide the handler function for the env endpoint
func getEnvHandler(config *Config) http.HandlerFunc {
variables, _ := encodeJSON(getEnvironmentVariables(config))
return func(writer http.ResponseWriter, _ *http.Request) {
writer.Header().Add(contentTypeHeader, applicationJSONContentType)
_, _ = writer.Write(variables)
}
}