I am trying to embed a static site (and SPA) into my Go code. The high level structure of my project is
.
├── web.go
└── spa/
└── index.html
My intent is to have http://localhost:8090/ serving index.html.
The relevant code to do that is
//go:embed spa
var spa embed.FS
log.Info("starting api server")
r := mux.NewRouter()
r.Handle("/", http.FileServer(http.FS(spa)))
log.Fatal(http.ListenAndServe(":8090", r))
When accessing http://localhost:8090/, I get
- a directory listing page with a single link
spa - upon clicking on this link I get a
404 page not found
How should I set this up?