Step 2: embed one file
This commit is contained in:
parent
36f5dde838
commit
a01f4049d3
8
main.go
8
main.go
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user