Finaliser implémentation de HandleDocumentationResponse #132

Merged
vlbeaudoin merged 1 commit from fix/handle-documentation-response into main 2023-08-20 18:36:33 -04:00
2 changed files with 21 additions and 5 deletions
templates/html
web_handlers

View file

@ -12,7 +12,7 @@
<div class="wrapper documentationWrapper">
<h1 class="heading1">Documentation</h1>
<p>
{{ range . }}
{{ range .Data.Buckets }}
{{ $bucket_name := .Name }}
{{ $bucket_display_name := .DisplayName }}
<details class="documentationCategorie">
@ -26,6 +26,9 @@
</details>
{{ end }}
</p>
<p>
{{ .Message }}
</p>
</div>
</body>
</html>

View file

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