2017-04-03 14:08:01 +02:00
|
|
|
package main
|
2017-03-30 22:48:27 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
2017-04-03 14:08:01 +02:00
|
|
|
// DeleteObjectHandler deletes an object
|
|
|
|
func DeleteObjectHandler(s3 S3Client) http.Handler {
|
2017-03-30 22:48:27 +02:00
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
|
|
|
|
err := s3.RemoveObject(vars["bucketName"], vars["objectName"])
|
|
|
|
if err != nil {
|
2017-04-09 16:28:57 +02:00
|
|
|
handleHTTPError(w, http.StatusInternalServerError, err)
|
2017-03-30 22:48:27 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-03 08:44:09 +02:00
|
|
|
w.WriteHeader(http.StatusNoContent)
|
2017-03-30 22:48:27 +02:00
|
|
|
})
|
|
|
|
}
|