Finaliser implémentation de HandleDocumentationResponse
This commit is contained in:
parent
8c4fde507b
commit
502b57bcd5
2 changed files with 21 additions and 5 deletions
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue