9 Commits
Author SHA1 Message Date
sm efb2d846c3 Adds logging 2018-02-07 15:17:58 -08:00
sm 0964cece0c bump to v0.0.9
I forgot to run make before making the docker image.
2018-02-07 14:47:57 -08:00
sm fdba7a7ecd Adds liveness and readiness 2018-02-07 13:58:15 -08:00
sm 54ced08b5a Added env route 2018-02-07 13:55:26 -08:00
sm 19adf9cb94 fixed bug 2018-01-10 10:18:37 -08:00
sm 79107389cc introduce a bug 2018-01-10 10:16:19 -08:00
sm bdab1c1346 bump version 2018-01-10 09:51:02 -08:00
sm f13ff6199f adds support for printing hostname 2018-01-10 09:49:42 -08:00
sm 2f566d692a bumps version 2018-01-09 16:33:41 -08:00
+24 -1
View File
@@ -2,22 +2,45 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt"
"log" "log"
"net/http" "net/http"
"os"
) )
const version = "v0.0.10"
type v struct { type v struct {
Hostname string `json:"hostname"`
V string `json:"version"` V string `json:"version"`
} }
func main() { func main() {
hn, err := os.Hostname()
if err != nil {
log.Fatalf("hostname: %+v", err)
}
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
r := v{"v0.0.1"} r := v{
Hostname: hn,
V: version,
}
if err := json.NewEncoder(w).Encode(r); err != nil { if err := json.NewEncoder(w).Encode(r); err != nil {
log.Printf("json: %+v", err) 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)
}
})
http.HandleFunc("/live", func(w http.ResponseWriter, req *http.Request) {
log.Printf("live")
})
http.HandleFunc("/ready", func(w http.ResponseWriter, req *http.Request) {
log.Printf("ready")
})
if err := http.ListenAndServe(":8080", nil); err != nil { if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatalf("listen and serve: %v", err) log.Fatalf("listen and serve: %v", err)
} }