Ajouter models/ pour type Bucket

models.Bucket est utilisé dans cmd/server pour contenir les données
relatives à la documentation dans certaines routes html
This commit is contained in:
Victor Lacasse-Beaudoin 2023-08-19 14:48:08 -04:00
parent 966dc49a9e
commit 0f60e58ec2
3 changed files with 15 additions and 23 deletions

View file

@ -16,6 +16,8 @@ ADD config/ config/
ADD media/ media/
ADD models/ models/
ADD templates/ templates/
ADD serverhandlers/ serverhandlers/

View file

@ -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
}

7
models/models.go Normal file
View file

@ -0,0 +1,7 @@
package models
type Bucket struct {
Name string
DisplayName string
Documents []string
}