s3manager-web/delete-bucket.go

24 lines
473 B
Go
Raw Normal View History

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
// DeleteBucketHandler deletes a bucket
func DeleteBucketHandler(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.RemoveBucket(vars["bucketName"])
if err != nil {
msg := "error removing bucket"
2017-04-03 14:08:01 +02:00
handleHTTPError(w, msg, err, http.StatusInternalServerError)
2017-03-30 22:48:27 +02:00
return
}
w.WriteHeader(http.StatusNoContent)
})
}