Ajouter framework de documentation #35

Merged
vlbeaudoin merged 10 commits from feature/minio into main 2023-04-24 16:44:33 -04:00
Showing only changes of commit 8f5d3794f4 - Show all commits

View file

@ -84,7 +84,7 @@ func RunServer() {
e.GET("/v1", handleV1) e.GET("/v1", handleV1)
e.GET("/v1/health", handleV1Health) e.GET("/v1/bucket", handleV1Bucket)
// Static Routes // Static Routes
@ -128,10 +128,9 @@ func handleV1(c echo.Context) error {
return c.JSON(http.StatusOK, routes) return c.JSON(http.StatusOK, routes)
} }
// handleV1Health affiche l'état de connexion à la base de données // handleV1Bucket affiche les buckets permis par server.documents.buckets, qui existent.
func handleV1Health(c echo.Context) error { func handleV1Bucket(c echo.Context) error {
documents_buckets := viper.GetStringSlice("server.documents.buckets") documents_buckets := viper.GetStringSlice("server.documents.buckets")
documents_endpoint := viper.GetString("server.documents.endpoint") documents_endpoint := viper.GetString("server.documents.endpoint")
documents_access_key_id := viper.GetString("server.documents.access_key_id") documents_access_key_id := viper.GetString("server.documents.access_key_id")
documents_secret_access_key := viper.GetString("server.documents.secret_access_key") documents_secret_access_key := viper.GetString("server.documents.secret_access_key")
@ -142,21 +141,20 @@ func handleV1Health(c echo.Context) error {
return c.JSON(http.StatusInternalServerError, err) return c.JSON(http.StatusInternalServerError, err)
} }
if len(documents_buckets) == 0 { var buckets []string
return c.JSON(http.StatusOK, nil)
}
message := make(map[string]interface{}, len(documents_buckets))
for _, bucket_name := range documents_buckets { for _, bucket_name := range documents_buckets {
exists, err := client.BucketExists(bucket_name) exists, err := client.BucketExists(bucket_name)
if err != nil { if err != nil {
return c.JSON(http.StatusInternalServerError, err) return c.JSON(http.StatusInternalServerError, err)
} }
message[bucket_name] = exists
if exists {
buckets = append(buckets, bucket_name)
}
} }
return c.JSON(http.StatusOK, message) return c.JSON(http.StatusOK, buckets)
} }
// HTML Handlers // HTML Handlers