2017-05-08 23:07:07 +02:00
|
|
|
package s3manager
|
2017-03-30 22:48:27 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2017-05-25 18:33:44 +02:00
|
|
|
"github.com/pkg/errors"
|
2017-03-30 22:48:27 +02:00
|
|
|
)
|
|
|
|
|
2017-05-08 23:07:07 +02:00
|
|
|
// DeleteObjectHandler deletes an object.
|
|
|
|
func DeleteObjectHandler(s3 S3) http.Handler {
|
2017-03-30 22:48:27 +02:00
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
vars := mux.Vars(r)
|
2017-04-21 15:42:00 +02:00
|
|
|
bucketName := vars["bucketName"]
|
|
|
|
objectName := vars["objectName"]
|
|
|
|
err := s3.RemoveObject(bucketName, objectName)
|
2017-03-30 22:48:27 +02:00
|
|
|
if err != nil {
|
2017-05-25 18:33:44 +02:00
|
|
|
handleHTTPError(w, errors.Wrap(err, "error removing object"))
|
2017-03-30 22:48:27 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-10 14:19:27 +02:00
|
|
|
w.WriteHeader(http.StatusNoContent)
|
2017-03-30 22:48:27 +02:00
|
|
|
})
|
|
|
|
}
|