Is there a way to use http.ServeFile() of a file from embed.FS?
Closed this issue · 2 comments
Drugoy commented
Suppose you have a FS structure of your project
├── go.mod
├── main.go
└── static/
├── global.css
└── page.html
and you would like to serve contents of page.html on "/" path on your web server.
I only found solution using embededFiles.ReadFile("static/page.html")
, but then I have to use a Handler and w.Write()
the result from there, which is less elegant than http.ServeFile()
, which I failed to adopt as a solution to the task.
earthboundkid commented
Drugoy commented
Thank you for both links! Very spot on, I highly appreciate your reply.