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))
}

The entire golang file and the html file are available 
in https://github.com/psankar/static-serve

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 ?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/bd659773-029a-4a39-b845-d10983654597n%40googlegroups.com.

Reply via email to