1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-25 06:49:23 +01:00

Adds version

This commit is contained in:
Amir Raminfar
2018-11-01 12:00:03 -07:00
parent 22108a2782
commit 17e08c02bb

View File

@@ -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 {