s3manager-web/internal/app/s3manager/delete_object.go
Lena Fuhrimann 0a81f4a031 Use Go 1.13
2020-02-17 09:38:47 +01:00

24 lines
523 B
Go

package s3manager
import (
"fmt"
"net/http"
"github.com/matryer/way"
)
// HandleDeleteObject deletes an object.
func HandleDeleteObject(s3 S3) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
bucketName := way.Param(r.Context(), "bucketName")
objectName := way.Param(r.Context(), "objectName")
err := s3.RemoveObject(bucketName, objectName)
if err != nil {
handleHTTPError(w, fmt.Errorf("error removing object: %w", err))
return
}
w.WriteHeader(http.StatusNoContent)
}
}