On Mar 30, 5:53 pm, Kyle Lemons <
kev...@google.com> wrote:
> Reread your logic; it's doing what you told it to do. serveFoo returns a
> function which calls serveFile on each entry in the slice, in order,
> regardless of path.
>
> You probably want a loop over the files that calls Handle with ServeFile
> instead of the other way around.
I don't know why I had in mind that it has to be done as I done in the
first time. Thanks
// * * *
func serveFoo(file string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, file)
}
}
for _, v := range files {
http.HandleFunc(v, serveFoo(v))
}
// * * *
Note: I hope it works with a lot of files. I'll use a slice with more
than 25k files