28 lines
549 B
Go
28 lines
549 B
Go
package cli
|
|
import (
|
|
"net/http"
|
|
"slices"
|
|
"log"
|
|
"maps"
|
|
"encoding/json"
|
|
"coopcloud.tech/abra/pkg/recipe"
|
|
|
|
)
|
|
|
|
func (h *abraHandler) handleListCatalogue(w http.ResponseWriter, r *http.Request) {
|
|
offline := false
|
|
catl, err := recipe.ReadRecipeCatalogue(offline)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
vals := slices.Collect(maps.Values(catl))
|
|
|
|
jsonBytes, err := json.Marshal(vals)
|
|
if err != nil {
|
|
InternalServerError(w, err)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write(jsonBytes)
|
|
} |