mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
fix: check if controllers row is empty on GET /api/v1/controllers
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user