fix(get): answer with valid json array
build / Go-Build (push) Failing after 13m5s

This commit is contained in:
2026-05-25 23:55:24 +02:00
parent 48291430f5
commit 54a16fab4a
+9 -18
View File
@@ -14,26 +14,17 @@ func Get(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Cannot fetch svgs from database", http.StatusInternalServerError)
return
}
/*
data, err := json.Marshal(svgs)
data, err := json.Marshal(svgs)
if err != nil {
http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError)
return
}
if err != nil {
http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError)
return
}
_, err = w.Write(data)
_, err = w.Write(data)
if err != nil {
http.Error(w, "Could not write data.", http.StatusInternalServerError)
return
}
*/
w.Header().Add("Content-Type", "application/json")
enc := json.NewEncoder(w)
for _, svg := range svgs {
enc.Encode(svg)
if err != nil {
http.Error(w, "Could not write data.", http.StatusInternalServerError)
return
}
}