s3manager-web/delete_bucket.go

22 lines
445 B
Go
Raw Normal View History

2017-05-08 23:07:07 +02:00
package s3manager
2017-03-30 22:48:27 +02:00
import (
"net/http"
"github.com/gorilla/mux"
)
2017-05-08 23:07:07 +02:00
// DeleteBucketHandler deletes a bucket.
func DeleteBucketHandler(s3 S3) http.Handler {
2017-03-30 22:48:27 +02:00
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2017-04-21 15:42:00 +02:00
bucketName := mux.Vars(r)["bucketName"]
err := s3.RemoveBucket(bucketName)
2017-03-30 22:48:27 +02:00
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-10 14:19:27 +02:00
w.WriteHeader(http.StatusNoContent)
2017-03-30 22:48:27 +02:00
})
}