diff --git a/main.go b/main.go index a9a3958..8e5ff4d 100644 --- a/main.go +++ b/main.go @@ -27,14 +27,9 @@ var ( noauth = flag.Bool("a", false, "dont use basic auth") ) -var ( - fileServer http.Handler -) - func main() { flag.Parse() - fileServer = http.FileServer(http.Dir("")) http.HandleFunc("/", handler) dockerhealth.Healthy = true @@ -94,8 +89,14 @@ func get(w http.ResponseWriter, r *http.Request) { return } - r.URL.Path = path - fileServer.ServeHTTP(w, r) + file, err := os.Open(path) + if err != nil { + handleError(w, r, err) + return + } + defer file.Close() + + io.Copy(w, file) } func put(w http.ResponseWriter, r *http.Request) { @@ -143,9 +144,6 @@ func head(w http.ResponseWriter, r *http.Request) { w.Header().Add("File-Owner", username) w.Header().Add("Group-Owner", groupname) } - - r.URL.Path = path - fileServer.ServeHTTP(w, r) } func delete(w http.ResponseWriter, r *http.Request) {