Implémenter HandleV1BucketListResponse
This commit is contained in:
parent
c8af2acae9
commit
d736d53a43
1 changed files with 23 additions and 9 deletions
|
@ -61,19 +61,24 @@ func HandleV1Seed(c echo.Context) error {
|
|||
|
||||
// HandleV1BucketList affiche les buckets permis par server.documents.buckets, qui existent.
|
||||
func HandleV1BucketList(c echo.Context) error {
|
||||
var response models.V1BucketListResponse
|
||||
|
||||
var cfg config.Config
|
||||
if err := viper.Unmarshal(&cfg); err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"error": err.Error(),
|
||||
})
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during viper.Unmarshal"
|
||||
// response.Error = err.Error()
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
||||
mediaClient, err := media.NewMediaClientFromViper()
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Error during media.NewMediaClientFromViper()",
|
||||
"error": err.Error(),
|
||||
})
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during media.NewMediaClientFromViper()"
|
||||
// response.Error = err.Error()
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
||||
var buckets = make(map[string]string)
|
||||
|
@ -81,7 +86,11 @@ func HandleV1BucketList(c echo.Context) error {
|
|||
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")
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during minio#BucketExists"
|
||||
// response.Error = err.Error()
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
||||
if exists {
|
||||
|
@ -89,7 +98,12 @@ func HandleV1BucketList(c echo.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, buckets)
|
||||
response.StatusCode = http.StatusOK
|
||||
response.Message = "Buckets list successful"
|
||||
response.Data.Buckets = buckets
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
//return c.JSON(response.StatusCode, response.Data.Buckets)
|
||||
}
|
||||
|
||||
func HandleV1BucketRead(c echo.Context) error {
|
||||
|
|
Loading…
Reference in a new issue