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

23 lines
457 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(bucketName)
if err != nil {
handleHTTPError(w, fmt.Errorf("error removing bucket: %w", err))
return
}
w.WriteHeader(http.StatusNoContent)
}
}