feat(colors): Add a route which lists all available controllers with their metadata

This commit is contained in:
Siesta
2025-07-28 21:36:06 +02:00
parent 9453fab912
commit b50a62a52d
3 changed files with 35 additions and 6 deletions
+10 -1
View File
@@ -14,9 +14,18 @@ import (
)
func RegisterColorRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/v1/colors/", middleware.WithAdminAuth(listColors))
mux.HandleFunc("GET /api/v1/colors/{ID}", middleware.WithAdminAuth(getCurrent))
mux.HandleFunc("PUT /api/v1/colors/{ID}", middleware.WithAdminAuth(setCurrent))
// mux.HandleFunc("WS /api/v1/ws/colors/{ID}", setCurrentWebsocket)
}
func listColors(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
colors, err := db.GetAllColors()
if err != nil {
utils.ErrorResponse(w, http.StatusInternalServerError, err.Error())
}
utils.SuccessResponse(w, http.StatusOK, colors)
}
func getCurrent(w http.ResponseWriter, r *http.Request) {