From 54ced08b5af27e3db7fba976c0cede67492f98c7 Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Thu, 1 Feb 2018 17:36:00 -0800 Subject: [PATCH] Added env route --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 200464f..8516f29 100644 --- a/main.go +++ b/main.go @@ -2,11 +2,14 @@ package main import ( "encoding/json" + "fmt" "log" "net/http" "os" ) +const version = "v0.0.7" + type v struct { Hostname string `json:"hostname"` V string `json:"version"` @@ -21,12 +24,17 @@ func main() { w.Header().Set("Content-Type", "application/json") r := v{ Hostname: hn, - V: "v0.0.5", + V: version, } if err := json.NewEncoder(w).Encode(r); err != nil { log.Printf("json: %+v", err) } }) + http.HandleFunc("/env", func(w http.ResponseWriter, req *http.Request) { + for _, line := range os.Environ() { + fmt.Fprintf(w, "%v\n", line) + } + }) if err := http.ListenAndServe(":8080", nil); err != nil { log.Fatalf("listen and serve: %v", err) }