Fix serverhandlers usage of map[string]string buckets

This commit is contained in:
Victor Lacasse-Beaudoin 2023-08-15 15:52:03 -04:00
parent 0a6008189c
commit 9bcf49b5e9

View file

@ -72,16 +72,16 @@ func HandleV1BucketList(c echo.Context) error {
})
}
var buckets []string
var buckets = make(map[string]string)
for _, bucket_name := range cfg.Server.Documents.Buckets {
for bucket_name, bucket_display_name := range cfg.Server.Documents.Buckets {
exists, err := mediaClient.MinioClient.BucketExists(context.Background(), bucket_name)
if err != nil {
return c.JSON(http.StatusInternalServerError, "Error during minio#BucketExists")
}
if exists {
buckets = append(buckets, bucket_name)
buckets[bucket_name] = bucket_display_name
}
}
@ -99,7 +99,7 @@ func HandleV1BucketRead(c echo.Context) error {
bucket := c.Param("bucket")
allowed := false
for _, bucket_allowed := range cfg.Server.Documents.Buckets {
for bucket_allowed := range cfg.Server.Documents.Buckets {
if bucket == bucket_allowed {
allowed = true
}
@ -171,7 +171,7 @@ func HandleV1DocumentCreate(c echo.Context) error {
}
allowed := false
for _, bucket_allowed := range cfg.Server.Documents.Buckets {
for bucket_allowed := range cfg.Server.Documents.Buckets {
if bucket == bucket_allowed {
allowed = true
}
@ -240,7 +240,7 @@ func HandleV1DocumentRead(c echo.Context) error {
document := c.Param("document")
allowed := false
for _, bucket_allowed := range cfg.Server.Documents.Buckets {
for bucket_allowed := range cfg.Server.Documents.Buckets {
if bucket == bucket_allowed {
allowed = true
}
@ -317,7 +317,7 @@ func HandleV1DocumentDelete(c echo.Context) error {
document := c.Param("document")
allowed := false
for _, bucket_allowed := range cfg.Server.Documents.Buckets {
for bucket_allowed := range cfg.Server.Documents.Buckets {
if bucket == bucket_allowed {
allowed = true
}