refactor: déplacer handler SeedPOST à seed.go
This commit is contained in:
parent
787cb578a1
commit
d70b0643e8
2 changed files with 35 additions and 28 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"sort"
|
||||
|
||||
"codeberg.org/vlbeaudoin/pave"
|
||||
"git.agecem.com/agecem/agecem-org/apiresponse"
|
||||
"git.agecem.com/agecem/agecem-org/config"
|
||||
"git.agecem.com/agecem/agecem-org/media"
|
||||
"github.com/labstack/echo/v4"
|
||||
|
@ -26,30 +25,3 @@ func (h *V1Handler) V1GET(c echo.Context) error {
|
|||
sort.Slice(routes, func(i, j int) bool { return routes[i].Path < routes[j].Path })
|
||||
return c.JSON(http.StatusOK, routes)
|
||||
}
|
||||
|
||||
// V1SeedPOST créé des buckets dans minio selon la liste de buckets dans server.documents.buckets
|
||||
// Les buckets sont créés avec paramètres par défaut, et sont ensuite visible dans /v1/bucket.
|
||||
func (h *V1Handler) V1SeedPOST(c echo.Context) error {
|
||||
var response apiresponse.V1SeedPOST
|
||||
|
||||
new_buckets, err := h.MediaClient.Seed()
|
||||
response.Data.Buckets = new_buckets
|
||||
if err != nil {
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during mediaClient.Seed()"
|
||||
response.Error = err.Error()
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
||||
if len(new_buckets) == 0 {
|
||||
response.Message = "All buckets already exist"
|
||||
|
||||
} else {
|
||||
response.Message = "Buckets successfully created"
|
||||
}
|
||||
|
||||
response.StatusCode = http.StatusOK
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
|
35
apihandler/seed.go
Normal file
35
apihandler/seed.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package apihandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.agecem.com/agecem/agecem-org/apiresponse"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// V1SeedPOST créé des buckets dans minio selon la liste de buckets dans server.documents.buckets
|
||||
// Les buckets sont créés avec paramètres par défaut, et sont ensuite visible dans /v1/bucket.
|
||||
func (h *V1Handler) V1SeedPOST(c echo.Context) error {
|
||||
var response apiresponse.V1SeedPOST
|
||||
|
||||
new_buckets, err := h.MediaClient.Seed()
|
||||
response.Data.Buckets = new_buckets
|
||||
if err != nil {
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during mediaClient.Seed()"
|
||||
response.Error = err.Error()
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
||||
|
||||
if len(new_buckets) == 0 {
|
||||
response.Message = "All buckets already exist"
|
||||
|
||||
} else {
|
||||
response.Message = "Buckets successfully created"
|
||||
}
|
||||
|
||||
response.StatusCode = http.StatusOK
|
||||
|
||||
return c.JSON(response.StatusCode, response)
|
||||
}
|
Loading…
Reference in a new issue