diff --git a/api/api.go b/api/api.go index 15eb710..c648440 100644 --- a/api/api.go +++ b/api/api.go @@ -101,7 +101,7 @@ func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) ( return response, err } -func (a *API) ListBuckets() (response apiresponse.V1BucketList, err error) { +func (a *API) ListBuckets() (response apiresponse.V1BucketsGET, err error) { return response, a.Voki.Unmarshal(http.MethodGet, "/v1/bucket", nil, true, &response) } diff --git a/apihandler/apihandler.go b/apihandler/apihandler.go index 2e4fc37..78c3fc2 100644 --- a/apihandler/apihandler.go +++ b/apihandler/apihandler.go @@ -56,9 +56,9 @@ func (h *V1Handler) HandleV1Seed(c echo.Context) error { return c.JSON(response.StatusCode, response) } -// HandleV1BucketList affiche les buckets permis par server.documents.buckets, qui existent. -func (h *V1Handler) HandleV1BucketList(c echo.Context) error { - var response apiresponse.V1BucketList +// V1BucketsGET affiche les buckets permis par server.documents.buckets, qui existent. +func (h *V1Handler) V1BucketsGET(c echo.Context) error { + var response apiresponse.V1BucketsGET var buckets = make(map[string]string) diff --git a/apiresponse/bucket.go b/apiresponse/bucket.go index 476fcf1..21df0f5 100644 --- a/apiresponse/bucket.go +++ b/apiresponse/bucket.go @@ -1,6 +1,6 @@ package apiresponse -type V1BucketList struct { +type V1BucketsGET struct { Response Data struct { Buckets map[string]string diff --git a/cmd/server.go b/cmd/server.go index 073c447..22ca33d 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -230,7 +230,7 @@ func RunServer() { log.Fatal(err) } - groupV1.GET("/bucket", v1Handler.HandleV1BucketList) + groupV1.GET("/bucket", v1Handler.V1BucketsGET) groupV1.GET("/bucket/:bucket", v1Handler.HandleV1BucketRead) diff --git a/webhandler/webhandler.go b/webhandler/webhandler.go index 83bcb0b..b8df36a 100644 --- a/webhandler/webhandler.go +++ b/webhandler/webhandler.go @@ -53,18 +53,18 @@ func HandleVieEtudianteOrganisme(c echo.Context) error { func (h *WebHandler) HandleDocumentation(c echo.Context) error { var response webresponse.HandleDocumentationResponse - v1BucketListResponse, err := h.ApiClient.ListBuckets() + v1BucketsGET, err := h.ApiClient.ListBuckets() if err != nil { response.Error = err.Error() - response.Message = v1BucketListResponse.Message - response.StatusCode = v1BucketListResponse.StatusCode + response.Message = v1BucketsGET.Message + response.StatusCode = v1BucketsGET.StatusCode return c.Render(response.StatusCode, "documentation-html", response) } - //TODO check v1BucketListRespone StatusCode and Error + //TODO check v1BucketsGET StatusCode and Error - for bucket, displayName := range v1BucketListResponse.Data.Buckets { + for bucket, displayName := range v1BucketsGET.Data.Buckets { // TODO move call to dedicated API client method var v1BucketReadResponse apiresponse.V1BucketRead @@ -134,16 +134,16 @@ func HandleAdmin(c echo.Context) error { func (h *WebHandler) HandleAdminDocumentsUpload(c echo.Context) error { var response webresponse.HandleAdminDocumentsUploadResponse - v1BucketListResponse, err := h.ApiClient.ListBuckets() + v1BucketsGET, err := h.ApiClient.ListBuckets() if err != nil { - response.StatusCode = v1BucketListResponse.StatusCode + response.StatusCode = v1BucketsGET.StatusCode response.Error = err.Error() - response.Message = v1BucketListResponse.Message + response.Message = v1BucketsGET.Message return c.Render(response.StatusCode, "admin-upload-html", nil) } - for bucketName, displayName := range v1BucketListResponse.Data.Buckets { + for bucketName, displayName := range v1BucketsGET.Data.Buckets { response.Data.Buckets = append(response.Data.Buckets, models.Bucket{ Name: bucketName, DisplayName: displayName, @@ -157,16 +157,16 @@ func (h *WebHandler) HandleAdminDocumentsUpload(c echo.Context) error { func (h *WebHandler) HandleAdminDocumentsUploadPOST(c echo.Context) error { var response webresponse.HandleAdminDocumentsUploadResponse - v1BucketListResponse, err := h.ApiClient.ListBuckets() + v1BucketsGET, err := h.ApiClient.ListBuckets() if err != nil { - response.StatusCode = v1BucketListResponse.StatusCode - response.Message = v1BucketListResponse.Message + response.StatusCode = v1BucketsGET.StatusCode + response.Message = v1BucketsGET.Message response.Error = err.Error() return c.Render(response.StatusCode, "admin-upload-html", response) } - for bucketName, displayName := range v1BucketListResponse.Data.Buckets { + for bucketName, displayName := range v1BucketsGET.Data.Buckets { response.Data.Buckets = append(response.Data.Buckets, models.Bucket{ Name: bucketName, DisplayName: displayName,