Implémenter models.V1BucketReadResponse
This commit is contained in:
parent
cd8c2d4955
commit
a6ba62fd62
3 changed files with 44 additions and 23 deletions
|
@ -68,7 +68,6 @@ func HandleDocumentation(c echo.Context) error {
|
|||
|
||||
for bucket, displayName := range v1BucketListResponse.Data.Buckets {
|
||||
// TODO move call to dedicated API client method
|
||||
// TODO add Response type
|
||||
content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket))
|
||||
if err != nil {
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
|
@ -78,9 +77,9 @@ func HandleDocumentation(c echo.Context) error {
|
|||
return c.Render(response.StatusCode, "documentation-html", response)
|
||||
}
|
||||
|
||||
var documents []string
|
||||
var v1BucketReadResponse models.V1BucketReadResponse
|
||||
|
||||
err = json.Unmarshal(content, &documents)
|
||||
err = json.Unmarshal(content, &v1BucketReadResponse)
|
||||
if err != nil {
|
||||
response.StatusCode = http.StatusInternalServerError
|
||||
response.Message = "Error during json.Unmarshal /v1/bucket/:bucket"
|
||||
|
@ -110,13 +109,14 @@ func HandleDocumentation(c echo.Context) error {
|
|||
response.Data.Buckets = append(response.Data.Buckets, models.Bucket{
|
||||
Name: bucket,
|
||||
DisplayName: displayName,
|
||||
Documents: documents,
|
||||
Documents: v1BucketReadResponse.Data.Keys,
|
||||
})
|
||||
}
|
||||
|
||||
sort.SliceStable(response.Data.Buckets, func(i, j int) bool { return response.Data.Buckets[i].Name < response.Data.Buckets[j].Name })
|
||||
|
||||
response.StatusCode = http.StatusOK
|
||||
//response.Message = "HandleDocumentation ok"
|
||||
|
||||
// TODO render .Message
|
||||
return c.Render(response.StatusCode, "documentation-html", response)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue