Add support for DELETE method
git-svn-id: https://svn.yakumo.dev/yakumo.izuru/marisa/trunk@64 d6811dac-2434-b64a-9ddc-f563ab233461
This commit is contained in:
parent
3efc95d373
commit
981d705107
23
partage.go
23
partage.go
@ -243,12 +243,35 @@ func uploaderGet(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, conf.rootdir+filename)
|
||||
}
|
||||
|
||||
func uploaderDelete(w http.ResponseWriter, r *http.Request) {
|
||||
// r.URL.Path is sanitized regarding "." and ".."
|
||||
filename := r.URL.Path
|
||||
filepath := conf.filepath + filename
|
||||
|
||||
if verbose {
|
||||
log.Printf("Deleting file %s", filepath)
|
||||
}
|
||||
|
||||
f, err := os.Open(filepath)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
f.Close()
|
||||
|
||||
// Force file expiration
|
||||
writemeta(filepath, 0)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func uploader(w http.ResponseWriter, r *http.Request) {
|
||||
if verbose {
|
||||
log.Printf("%s: <%s> %s %s %s", r.Host, r.RemoteAddr, r.Method, r.RequestURI, r.Proto)
|
||||
}
|
||||
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
uploaderDelete(w, r)
|
||||
case "POST":
|
||||
uploaderPost(w, r)
|
||||
case "PUT":
|
||||
|
Loading…
x
Reference in New Issue
Block a user