From 502b57bcd57f587ef555959c766078dda66c1845 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sun, 20 Aug 2023 18:35:07 -0400 Subject: [PATCH] =?UTF-8?q?Finaliser=20impl=C3=A9mentation=20de=20HandleDo?= =?UTF-8?q?cumentationResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/html/documentation.gohtml | 5 ++++- web_handlers/web_handlers.go | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/templates/html/documentation.gohtml b/templates/html/documentation.gohtml index ab74478..5fd55dc 100644 --- a/templates/html/documentation.gohtml +++ b/templates/html/documentation.gohtml @@ -12,7 +12,7 @@

Documentation

- {{ range . }} + {{ range .Data.Buckets }} {{ $bucket_name := .Name }} {{ $bucket_display_name := .DisplayName }}

@@ -26,6 +26,9 @@
{{ end }}

+

+ {{ .Message }} +

diff --git a/web_handlers/web_handlers.go b/web_handlers/web_handlers.go index dc45dfb..872aed5 100644 --- a/web_handlers/web_handlers.go +++ b/web_handlers/web_handlers.go @@ -48,7 +48,11 @@ func HandleDocumentation(c echo.Context) error { client, err := api.NewApiClientFromViper() if err != nil { - return c.Render(http.StatusInternalServerError, "documentation-html", nil) + response.StatusCode = http.StatusInternalServerError + response.Message = "Error during api.NewApiClientFromViper()" + response.Error = err.Error() + + return c.Render(response.StatusCode, "documentation-html", response) } v1BucketListResponse, err := client.ListBuckets() @@ -67,14 +71,22 @@ func HandleDocumentation(c echo.Context) error { // TODO add Response type content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket)) if err != nil { - return c.Render(http.StatusInternalServerError, "documentation-html", nil) + response.StatusCode = http.StatusInternalServerError + response.Message = "Error during /v1/bucket/:bucket" + response.Error = err.Error() + + return c.Render(response.StatusCode, "documentation-html", response) } var documents []string err = json.Unmarshal(content, &documents) if err != nil { - return c.Render(http.StatusInternalServerError, "documentation-html", nil) + response.StatusCode = http.StatusInternalServerError + response.Message = "Error during json.Unmarshal /v1/bucket/:bucket" + response.Error = err.Error() + + return c.Render(response.StatusCode, "documentation-html", response) } // Ce bloc retire tous les caractères spéciaux d'une string @@ -107,7 +119,8 @@ func HandleDocumentation(c echo.Context) error { response.StatusCode = http.StatusOK // TODO render .Message - return c.Render(response.StatusCode, "documentation-html", response.Data.Buckets) + return c.Render(response.StatusCode, "documentation-html", response) + //return c.Render(response.StatusCode, "documentation-html", response.Data.Buckets) } func HandleFormulaires(c echo.Context) error { -- 2.45.2