http.FileServer takes a FileSystem implementation, http.Dir will basically allow accessing any dir/file that's why you get the index for directories.
You can create a custom FileSystem implementation: https://play.golang.org/p/BcMLX2NWW7 On Thu, Sep 15, 2016 at 1:40 PM tobyjaguar <tal...@gmail.com> wrote: > Is possible to serve a directory, http.FileServer(http.Dir(".")), without > listing the directory contents of that directory by navigating one folder > above it in the browser? > > http.Handle("/img/", http.FileServer(http.Dir("static"))) > > <img src="/img/image.jpg> is served, but the browser will index everything > in /img/ > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.