From 0f60e58ec21abb15d20be9bbd4c3ccb8cc03baeb Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 19 Aug 2023 14:48:08 -0400 Subject: [PATCH] Ajouter models/ pour type Bucket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit models.Bucket est utilisé dans cmd/server pour contenir les données relatives à la documentation dans certaines routes html --- Dockerfile | 2 ++ cmd/server.go | 29 ++++++----------------------- models/models.go | 7 +++++++ 3 files changed, 15 insertions(+), 23 deletions(-) create mode 100644 models/models.go diff --git a/Dockerfile b/Dockerfile index 7497889..a53152d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ ADD config/ config/ ADD media/ media/ +ADD models/ models/ + ADD templates/ templates/ ADD serverhandlers/ serverhandlers/ diff --git a/cmd/server.go b/cmd/server.go index e37b48f..8ba30e8 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -21,6 +21,7 @@ import ( "git.agecem.com/agecem/agecem-org/api" "git.agecem.com/agecem/agecem-org/config" "git.agecem.com/agecem/agecem-org/media" + "git.agecem.com/agecem/agecem-org/models" "git.agecem.com/agecem/agecem-org/public" "git.agecem.com/agecem/agecem-org/serverhandlers" "git.agecem.com/agecem/agecem-org/templates" @@ -306,13 +307,7 @@ func handleDocumentation(c echo.Context) error { return c.Render(http.StatusInternalServerError, "documentation-html", nil) } - type Bucket struct { - Name string - DisplayName string - Documents []string - } - - var data []Bucket + var data []models.Bucket for bucket, displayName := range buckets { content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket)) @@ -345,7 +340,7 @@ func handleDocumentation(c echo.Context) error { documents_processed := documents */ - data = append(data, Bucket{ + data = append(data, models.Bucket{ Name: bucket, DisplayName: displayName, Documents: documents, @@ -408,19 +403,13 @@ func handleAdminDocumentsUpload(c echo.Context) error { return c.Render(http.StatusInternalServerError, "documentation-html", nil) } - type Bucket struct { - Name string - DisplayName string - Documents []string - } - var data struct { - Buckets []Bucket + Buckets []models.Bucket Message string } for bucketName, displayName := range buckets { - data.Buckets = append(data.Buckets, Bucket{ + data.Buckets = append(data.Buckets, models.Bucket{ Name: bucketName, DisplayName: displayName, }) @@ -430,14 +419,8 @@ func handleAdminDocumentsUpload(c echo.Context) error { } func handleAdminDocumentsUploadPOST(c echo.Context) error { - type Bucket struct { - Name string - DisplayName string - Documents []string - } - var data struct { - Buckets []Bucket + Buckets []models.Bucket Message string } diff --git a/models/models.go b/models/models.go new file mode 100644 index 0000000..9ef3c9e --- /dev/null +++ b/models/models.go @@ -0,0 +1,7 @@ +package models + +type Bucket struct { + Name string + DisplayName string + Documents []string +}