Maybe I'm looking at the wrong places, but I cannot find an example of using go.rice with http.ServeFile()
. Basically what I want is serve a boxed file with http.ServeFile()
. What I have now is the following. As you can see I'm looking for a way to get the string location of a boxed file, since http.ServeFile requires that. I don't know how to get it. Any suggestions?
var StaticBox *rice.Box
func NewStaticBox() {
StaticBox = rice.MustFindBox("../../static")
}
func Static(req *http.Request, resp *http.Response) {
stringToBoxedFile := WHAT-TO-DO-HERE
http.ServeFile(req, resp, stringToBoxedFile)
}
I can use the rice.box in various ways. I can get a file contents as a string with StaticBox.String()
, etc. But now I want a string as a "location" to a boxed file.