s3manager-web/internal/app/s3manager/delete_bucket.go
2021-08-17 15:44:49 +02:00

23 lines
470 B
Go

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