s3manager-web/delete-object.go
2017-04-10 07:36:02 +02:00

24 lines
511 B
Go

package main
import (
"net/http"
"github.com/gorilla/mux"
)
// DeleteObjectHandler deletes an object
func DeleteObjectHandler(s3 S3Client) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
err := s3.RemoveObject(vars["bucketName"], vars["objectName"])
if err != nil {
handleHTTPError(w, http.StatusInternalServerError, err)
return
}
code := http.StatusNoContent
w.WriteHeader(code)
w.Write([]byte(http.StatusText(code)))
})
}