mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-25 06:49:23 +01:00
Adds version
This commit is contained in:
8
main.go
8
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 {
|
||||
|
||||
Reference in New Issue
Block a user