From a01f4049d3d24d2720b9c7a5c093e8c2dd53818c Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 29 May 2024 12:12:13 +0200 Subject: [PATCH] Step 2: embed one file --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 6143cfd..1ce0d22 100644 --- a/main.go +++ b/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)) }