Open ghost opened 4 years ago
If it's for http servefile I had used it like
file, err := pkger.Open(h.indexPath)
if err != nil {
// handle error .....
return
}
http.FileServer(file).ServeHTTP(w, r)
I had an redirect exception with the solution above, I get it work with:
entrypoint := "/api/public/index.html"
f, err := pkger.Open(entrypoint)
d, err := pkger.Stat(f.Info().Dir)
if err != nil {
// handle error .....
return
}
http.ServeContent(w, r, f.Name(), d.ModTime(), f)
I'm sometimes in the situation where a library wants a file that is next to my executable and therefore waits for a string parameter to give it the file. I would like to take advantage of pkger. How can I get a filepath string from a pkger file to give it to functions that are waiting for a file with a string?
Example : https://golang.org/pkg/net/http/#ServeFile