Step 2: embed one file

This commit is contained in:
nemunaire 2024-05-29 12:12:13 +02:00
parent 36f5dde838
commit a01f4049d3

View File

@ -1,11 +1,15 @@
package main
import (
_ "embed"
"io"
"log"
"net/http"
)
//go:embed index.html
var index []byte
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")
@ -16,7 +20,9 @@ func main() {
}
})
http.Handle("GET /", http.FileServer(http.Dir(".")))
http.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
w.Write(index)
})
log.Fatal(http.ListenAndServe(":8080", nil))
}