This commit is contained in:
+9
-18
@@ -14,26 +14,17 @@ func Get(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Cannot fetch svgs from database", http.StatusInternalServerError)
|
http.Error(w, "Cannot fetch svgs from database", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
/*
|
data, err := json.Marshal(svgs)
|
||||||
data, err := json.Marshal(svgs)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError)
|
http.Error(w, "An Error occurred while encoding json.", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = w.Write(data)
|
_, err = w.Write(data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Could not write data.", http.StatusInternalServerError)
|
http.Error(w, "Could not write data.", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
w.Header().Add("Content-Type", "application/json")
|
|
||||||
enc := json.NewEncoder(w)
|
|
||||||
|
|
||||||
for _, svg := range svgs {
|
|
||||||
enc.Encode(svg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user