allows cross origin downloads

This commit is contained in:
Stephen McQuay 2015-08-30 01:42:03 -07:00
parent 9bd7e5fb14
commit 974f6aef63

View File

@ -14,6 +14,7 @@ var hidden = flag.Bool("hidden", false, "allow serving hidden dirs")
func logger(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Access-Control-Allow-Origin", "*")
log.Printf("%s: %s\n", r.RemoteAddr, r.URL)
if !*hidden && strings.Contains(r.URL.Path, "/.") {
http.Error(w, "hidden files and directories are not allowed", http.StatusUnauthorized)