I have the following go code where I try to embed a html file from a public directory and running into HTTP 404. What am I doing wrong ? Relevant code snippet:
// go:embed public
var public embed.FS
func main() {
// cd to the public directory
publicFS, err := fs.Sub(public, "public")
if err != nil {
log.Fatal(err)
}
http.Handle("/embedded/", http.FileServer(http.FS(publicFS)))
http.Handle("/public/",
http.StripPrefix("/public/", http.FileServer(http.Dir("public"))))
log.Fatal(http.ListenAndServe(":8080", nil))
}
I have tried adding even a `http.StripPrefix` for the `/embedded/` path also but even that does not help. Any pointers on what I am doing wrong ?