2024-05-29 10:09:31 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-29 10:12:13 +00:00
|
|
|
_ "embed"
|
2024-05-29 10:09:31 +00:00
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-05-29 10:12:13 +00:00
|
|
|
//go:embed index.html
|
|
|
|
var index []byte
|
|
|
|
|
2024-05-29 10:09:31 +00:00
|
|
|
func main() {
|
|
|
|
http.HandleFunc("GET /containers", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
rd, err := curl("/var/run/docker.sock", "GET", "http://d/v1.43/containers/json?all=true")
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
} else {
|
|
|
|
io.Copy(w, rd)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-05-29 10:12:13 +00:00
|
|
|
http.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.Write(index)
|
|
|
|
})
|
2024-05-29 10:09:31 +00:00
|
|
|
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
|
|
}
|