Step 3: embed.FS
This commit is contained in:
parent
a01f4049d3
commit
fe9b062c36
10
main.go
10
main.go
@ -1,14 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"embed"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed index.html
|
||||
var index []byte
|
||||
//go:embed index.html style.css
|
||||
var staticfiles embed.FS
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("GET /containers", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -20,9 +20,7 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
http.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(index)
|
||||
})
|
||||
http.Handle("GET /", http.FileServer(http.FS(staticfiles)))
|
||||
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user