Suggestion: implement Stat on the output of Dir
sagikazarmark opened this issue · comments
I use pkger in a project where I need to serve static files, but I need to manually handle 404, so I started writing the following:
dir := pkger.Dir("/static")
fs := http.FileServer(dir)
handler := func(w http.ResponseWriter, r *http.Request) {
s, err := dir.Stat("something")
if err != nil /*or not found*/ {
// handle 404
}
fs.ServeHTTP(w, r)
}
But returned Dir doesn't implement the Stat
method. Using Dir
would actually be a nice way to handle file prefixes, so we wouldn't have to repeat them and just pass around the output of Dir
. (Could even write an interface for that)