fix: check if controllers row is empty on GET /api/v1/controllers

This commit is contained in:
Kaaninchen
2026-08-03 19:14:08 +02:00
parent 3f470096ce
commit 0ea3d4f4ac
+7
View File
@@ -21,11 +21,18 @@ func RegisterColorRoutes(mux *http.ServeMux) {
func listColors(w http.ResponseWriter, r *http.Request) { func listColors(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close() defer r.Body.Close()
colors, err := db.GetAllColors() colors, err := db.GetAllColors()
if err != nil { if err != nil {
utils.ErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.ErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if colors == nil {
utils.ErrorResponse(w, http.StatusOK, "No controllers found")
return
}
utils.SuccessResponse(w, http.StatusOK, colors) utils.SuccessResponse(w, http.StatusOK, colors)
} }