From 17e08c02bbe382fcfe1601a6633cb69f832fa1d2 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Thu, 1 Nov 2018 12:00:03 -0700 Subject: [PATCH] Adds version --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 6bfdaca5..492fe823 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "encoding/json" "flag" + "fmt" "log" "net/http" @@ -36,6 +37,7 @@ func main() { box := packr.NewBox("./static") http.HandleFunc("/api/containers.json", listContainers) http.HandleFunc("/api/logs", logs) + http.HandleFunc("/version", versionHandler) http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { fileServer := http.FileServer(box) if box.Has(req.URL.Path) { @@ -49,6 +51,12 @@ func main() { log.Fatal(http.ListenAndServe(*addr, nil)) } +func versionHandler(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, version) + fmt.Fprintln(w, commit) + fmt.Fprintln(w, date) +} + func listContainers(w http.ResponseWriter, r *http.Request) { containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) if err != nil {