Merge pull request 'Finaliser implémentation de HandleDocumentationResponse' (#132) from fix/handle-documentation-response into main
Reviewed-on: #132
This commit is contained in:
commit
79a5c06eae
2 changed files with 21 additions and 5 deletions
|
@ -12,7 +12,7 @@
|
||||||
<div class="wrapper documentationWrapper">
|
<div class="wrapper documentationWrapper">
|
||||||
<h1 class="heading1">Documentation</h1>
|
<h1 class="heading1">Documentation</h1>
|
||||||
<p>
|
<p>
|
||||||
{{ range . }}
|
{{ range .Data.Buckets }}
|
||||||
{{ $bucket_name := .Name }}
|
{{ $bucket_name := .Name }}
|
||||||
{{ $bucket_display_name := .DisplayName }}
|
{{ $bucket_display_name := .DisplayName }}
|
||||||
<details class="documentationCategorie">
|
<details class="documentationCategorie">
|
||||||
|
@ -26,6 +26,9 @@
|
||||||
</details>
|
</details>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
{{ .Message }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -48,7 +48,11 @@ func HandleDocumentation(c echo.Context) error {
|
||||||
|
|
||||||
client, err := api.NewApiClientFromViper()
|
client, err := api.NewApiClientFromViper()
|
||||||
if err != nil {
|
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()
|
v1BucketListResponse, err := client.ListBuckets()
|
||||||
|
@ -67,14 +71,22 @@ func HandleDocumentation(c echo.Context) error {
|
||||||
// TODO add Response type
|
// TODO add Response type
|
||||||
content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket))
|
content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket))
|
||||||
if err != nil {
|
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
|
var documents []string
|
||||||
|
|
||||||
err = json.Unmarshal(content, &documents)
|
err = json.Unmarshal(content, &documents)
|
||||||
if err != nil {
|
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
|
// 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
|
response.StatusCode = http.StatusOK
|
||||||
|
|
||||||
// TODO render .Message
|
// 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 {
|
func HandleFormulaires(c echo.Context) error {
|
||||||
|
|
Loading…
Reference in a new issue