23 lines
461 B
Go
23 lines
461 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
})
|
||
|
|
||
|
http.Handle("GET /", http.FileServer(http.Dir(".")))
|
||
|
|
||
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||
|
}
|