fix
This commit is contained in:
parent
225fe84a6b
commit
a4cb2922fa
18
main.go
18
main.go
@ -27,14 +27,9 @@ var (
|
|||||||
noauth = flag.Bool("a", false, "dont use basic auth")
|
noauth = flag.Bool("a", false, "dont use basic auth")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
fileServer http.Handler
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
fileServer = http.FileServer(http.Dir(""))
|
|
||||||
http.HandleFunc("/", handler)
|
http.HandleFunc("/", handler)
|
||||||
|
|
||||||
dockerhealth.Healthy = true
|
dockerhealth.Healthy = true
|
||||||
@ -94,8 +89,14 @@ func get(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.URL.Path = path
|
file, err := os.Open(path)
|
||||||
fileServer.ServeHTTP(w, r)
|
if err != nil {
|
||||||
|
handleError(w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
io.Copy(w, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
func put(w http.ResponseWriter, r *http.Request) {
|
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("File-Owner", username)
|
||||||
w.Header().Add("Group-Owner", groupname)
|
w.Header().Add("Group-Owner", groupname)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.URL.Path = path
|
|
||||||
fileServer.ServeHTTP(w, r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func delete(w http.ResponseWriter, r *http.Request) {
|
func delete(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user